Completed
Push — develop ( 75b835...a38a21 )
by Maxim
09:33 queued 04:23
created
manager/actions/files.dynamic.php 1 patch
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -565,6 +565,9 @@  discard block
 block discarded – undo
565 565
 
566 566
 }
567 567
 
568
+/**
569
+ * @param string $file
570
+ */
568 571
 function determineIcon($file, $selFile, $mode)
569 572
 {
570 573
     $icons = array(
@@ -709,6 +712,9 @@  discard block
 block discarded – undo
709 712
     return $path;
710 713
 }
711 714
 
715
+/**
716
+ * @param string $string
717
+ */
712 718
 function getExtension($string)
713 719
 {
714 720
     $pos = strrpos($string, '.');
@@ -744,6 +750,9 @@  discard block
 block discarded – undo
744 750
     return @mkdir($strPath);
745 751
 }
746 752
 
753
+/**
754
+ * @param string $type
755
+ */
747 756
 function logFileChange($type, $filename)
748 757
 {
749 758
     //global $_lang;
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 2 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -160,6 +160,11 @@  discard block
 block discarded – undo
160 160
 	return $output;
161 161
 }
162 162
 
163
+/**
164
+ * @param integer $parent
165
+ * @param string $filedir
166
+ * @param string $mode
167
+ */
163 168
 function importFiles($parent, $filedir, $files, $mode) {
164 169
 	global $modx;
165 170
 	global $_lang, $allowedfiles;
@@ -302,6 +307,9 @@  discard block
 block discarded – undo
302 307
 	}
303 308
 }
304 309
 
310
+/**
311
+ * @param string $directory
312
+ */
305 313
 function getFiles($directory, $listing = array(), $count = 0) {
306 314
 	global $_lang;
307 315
 	global $filesfound;
@@ -326,6 +334,9 @@  discard block
 block discarded – undo
326 334
 	return ($listing);
327 335
 }
328 336
 
337
+/**
338
+ * @param string $filepath
339
+ */
329 340
 function getFileContent($filepath) {
330 341
 	global $_lang;
331 342
 	// get the file
@@ -353,6 +364,9 @@  discard block
 block discarded – undo
353 364
 	return $new_array;
354 365
 }
355 366
 
367
+/**
368
+ * @param null|string $src
369
+ */
356 370
 function treatContent($src, $filename, $alias) {
357 371
 	global $modx;
358 372
 
Please login to merge, or discard this patch.
Indentation   +333 added lines, -333 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('import_static')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 // Files to upload
10 10
 $allowedfiles = array(
11
-	'html',
12
-	'htm',
13
-	'shtml',
14
-	'xml'
11
+    'html',
12
+    'htm',
13
+    'shtml',
14
+    'xml'
15 15
 );
16 16
 ?>
17 17
 	<script language="javascript">
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
-				?>
46
+            if(!isset($_POST['import'])) {
47
+                echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
+                ?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
51 51
 					<input type="hidden" name="a" value="95" />
@@ -85,375 +85,375 @@  discard block
 block discarded – undo
85 85
 					<a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a>
86 86
 				</form>
87 87
 			<?php
88
-			} else {
89
-			run();
90
-			$modx->clearCache('full');
91
-			?>
88
+            } else {
89
+            run();
90
+            $modx->clearCache('full');
91
+            ?>
92 92
 				<a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a>
93 93
 				<script type="text/javascript">
94 94
 					top.mainMenu.reloadtree();
95 95
 					parent.tree.ca = 'open';
96 96
 				</script>
97 97
 				<?php
98
-			}
99
-			?>
98
+            }
99
+            ?>
100 100
 		</div>
101 101
 	</div>
102 102
 
103 103
 <?php
104 104
 function run() {
105
-	global $modx, $_lang;
105
+    global $modx, $_lang;
106 106
 
107
-	$tbl_site_content = $modx->getFullTableName('site_content');
108
-	$output = '';
109
-	$maxtime = $_POST['maxtime'];
107
+    $tbl_site_content = $modx->getFullTableName('site_content');
108
+    $output = '';
109
+    $maxtime = $_POST['maxtime'];
110 110
 
111
-	if(!is_numeric($maxtime)) {
112
-		$maxtime = 30;
113
-	}
111
+    if(!is_numeric($maxtime)) {
112
+        $maxtime = 30;
113
+    }
114 114
 
115
-	@set_time_limit($maxtime);
115
+    @set_time_limit($maxtime);
116 116
 
117
-	$mtime = microtime();
118
-	$mtime = explode(' ', $mtime);
119
-	$mtime = $mtime[1] + $mtime[0];
120
-	$importstart = $mtime;
117
+    $mtime = microtime();
118
+    $mtime = explode(' ', $mtime);
119
+    $mtime = $mtime[1] + $mtime[0];
120
+    $importstart = $mtime;
121 121
 
122
-	if($_POST['reset'] == 'on') {
123
-		$modx->db->truncate($tbl_site_content);
124
-		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
125
-	}
122
+    if($_POST['reset'] == 'on') {
123
+        $modx->db->truncate($tbl_site_content);
124
+        $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
125
+    }
126 126
 
127
-	$parent = intval($_POST['parent']);
127
+    $parent = intval($_POST['parent']);
128 128
 
129
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
130
-		$filedir = MODX_BASE_PATH . 'temp/import/';
131
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
132
-		$filedir = MODX_BASE_PATH . 'assets/import/';
133
-	} else {
129
+    if(is_dir(MODX_BASE_PATH . 'temp/import')) {
130
+        $filedir = MODX_BASE_PATH . 'temp/import/';
131
+    } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
132
+        $filedir = MODX_BASE_PATH . 'assets/import/';
133
+    } else {
134 134
         $filedir = '';
135 135
     }
136 136
 
137
-	$filesfound = 0;
137
+    $filesfound = 0;
138 138
 
139
-	$files = getFiles($filedir);
140
-	$files = pop_index($files);
139
+    $files = getFiles($filedir);
140
+    $files = pop_index($files);
141 141
 
142
-	// no. of files to import
143
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
142
+    // no. of files to import
143
+    $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
144 144
 
145
-	// import files
146
-	if(0 < count($files)) {
147
-		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
148
-		importFiles($parent, $filedir, $files, 'root');
149
-	}
145
+    // import files
146
+    if(0 < count($files)) {
147
+        $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
148
+        importFiles($parent, $filedir, $files, 'root');
149
+    }
150 150
 
151
-	$mtime = microtime();
152
-	$mtime = explode(' ', $mtime);
153
-	$mtime = $mtime[1] + $mtime[0];
154
-	$importend = $mtime;
155
-	$totaltime = ($importend - $importstart);
156
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
151
+    $mtime = microtime();
152
+    $mtime = explode(' ', $mtime);
153
+    $mtime = $mtime[1] + $mtime[0];
154
+    $importend = $mtime;
155
+    $totaltime = ($importend - $importstart);
156
+    $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
157 157
 
158
-	if($_POST['convert_link'] == 'on') {
159
-		convertLink();
160
-	}
158
+    if($_POST['convert_link'] == 'on') {
159
+        convertLink();
160
+    }
161 161
 
162
-	return $output;
162
+    return $output;
163 163
 }
164 164
 
165 165
 function importFiles($parent, $filedir, $files, $mode) {
166
-	global $modx;
167
-	global $_lang, $allowedfiles;
168
-	global $search_default, $cache_default, $publish_default;
169
-
170
-	$tbl_site_content = $modx->getFullTableName('site_content');
171
-	$tbl_system_settings = $modx->getFullTableName('system_settings');
172
-
173
-	$createdby = $modx->getLoginUserID();
174
-	if(!is_array($files)) {
175
-		return;
176
-	}
177
-	if($_POST['object'] == 'all') {
178
-		$modx->config['default_template'] = '0';
179
-		$richtext = '0';
180
-	} else {
181
-		$richtext = '1';
182
-	}
183
-
184
-	foreach($files as $id => $value) {
185
-		if(is_array($value)) {
186
-			// create folder
187
-			$alias = $id;
188
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
189
-			$field = array();
190
-			$field['type'] = 'document';
191
-			$field['contentType'] = 'text/html';
192
-			$field['published'] = $publish_default;
193
-			$field['parent'] = $parent;
194
-			$field['alias'] = $modx->stripAlias($alias);
195
-			$field['richtext'] = $richtext;
196
-			$field['template'] = $modx->config['default_template'];
197
-			$field['searchable'] = $search_default;
198
-			$field['cacheable'] = $cache_default;
199
-			$field['createdby'] = $createdby;
200
-			$field['isfolder'] = 1;
201
-			$field['menuindex'] = 1;
202
-			$find = false;
203
-			foreach(array(
204
-						'index.html',
205
-						'index.htm'
206
-					) as $filename) {
207
-				$filepath = $filedir . $alias . '/' . $filename;
208
-				if($find === false && file_exists($filepath)) {
209
-					$file = getFileContent($filepath);
210
-					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
211
-
212
-					$date = filemtime($filepath);
213
-					$field['pagetitle'] = $pagetitle;
214
-					$field['longtitle'] = $pagetitle;
215
-					$field['description'] = $description;
216
-					$field['content'] = $modx->db->escape($content);
217
-					$field['createdon'] = $date;
218
-					$field['editedon'] = $date;
219
-					$newid = $modx->db->insert($field, $tbl_site_content);
220
-					if($newid) {
221
-						$find = true;
222
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
223
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
224
-					} else {
225
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
226
-						exit;
227
-					}
228
-				}
229
-			}
230
-			if($find === false) {
231
-				$date = time();
232
-				$field['pagetitle'] = '---';
233
-				$field['content'] = '';
234
-				$field['createdon'] = $date;
235
-				$field['editedon'] = $date;
236
-				$field['hidemenu'] = '1';
237
-				$newid = $modx->db->insert($field, $tbl_site_content);
238
-				if($newid) {
239
-					$find = true;
240
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
241
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
242
-				} else {
243
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
244
-					exit;
245
-				}
246
-			}
247
-		} else {
248
-			// create document
249
-			if($mode == 'sub' && $value == 'index.html') {
250
-				continue;
251
-			}
252
-			$filename = $value;
253
-			$fparts = explode('.', $value);
254
-			$alias = $fparts[0];
255
-			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
256
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
257
-
258
-			if(!in_array($ext, $allowedfiles)) {
259
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
260
-			} else {
261
-				$filepath = $filedir . $filename;
262
-				$file = getFileContent($filepath);
263
-				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
264
-
265
-				$date = filemtime($filepath);
266
-				$field = array();
267
-				$field['type'] = 'document';
268
-				$field['contentType'] = 'text/html';
269
-				$field['pagetitle'] = $pagetitle;
270
-				$field['longtitle'] = $pagetitle;
271
-				$field['description'] = $description;
272
-				$field['alias'] = $modx->stripAlias($alias);
273
-				$field['published'] = $publish_default;
274
-				$field['parent'] = $parent;
275
-				$field['content'] = $modx->db->escape($content);
276
-				$field['richtext'] = $richtext;
277
-				$field['template'] = $modx->config['default_template'];
278
-				$field['searchable'] = $search_default;
279
-				$field['cacheable'] = $cache_default;
280
-				$field['createdby'] = $createdby;
281
-				$field['createdon'] = $date;
282
-				$field['editedon'] = $date;
283
-				$field['isfolder'] = 0;
284
-				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
285
-				$newid = $modx->db->insert($field, $tbl_site_content);
286
-				if($newid) {
287
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
288
-				} else {
289
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
290
-					exit;
291
-				}
292
-
293
-				$is_site_start = false;
294
-				if($filename == 'index.html') {
295
-					$is_site_start = true;
296
-				}
297
-				if($is_site_start == true && $_POST['reset'] == 'on') {
298
-					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
299
-					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
300
-				}
301
-			}
302
-		}
303
-	}
166
+    global $modx;
167
+    global $_lang, $allowedfiles;
168
+    global $search_default, $cache_default, $publish_default;
169
+
170
+    $tbl_site_content = $modx->getFullTableName('site_content');
171
+    $tbl_system_settings = $modx->getFullTableName('system_settings');
172
+
173
+    $createdby = $modx->getLoginUserID();
174
+    if(!is_array($files)) {
175
+        return;
176
+    }
177
+    if($_POST['object'] == 'all') {
178
+        $modx->config['default_template'] = '0';
179
+        $richtext = '0';
180
+    } else {
181
+        $richtext = '1';
182
+    }
183
+
184
+    foreach($files as $id => $value) {
185
+        if(is_array($value)) {
186
+            // create folder
187
+            $alias = $id;
188
+            printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
189
+            $field = array();
190
+            $field['type'] = 'document';
191
+            $field['contentType'] = 'text/html';
192
+            $field['published'] = $publish_default;
193
+            $field['parent'] = $parent;
194
+            $field['alias'] = $modx->stripAlias($alias);
195
+            $field['richtext'] = $richtext;
196
+            $field['template'] = $modx->config['default_template'];
197
+            $field['searchable'] = $search_default;
198
+            $field['cacheable'] = $cache_default;
199
+            $field['createdby'] = $createdby;
200
+            $field['isfolder'] = 1;
201
+            $field['menuindex'] = 1;
202
+            $find = false;
203
+            foreach(array(
204
+                        'index.html',
205
+                        'index.htm'
206
+                    ) as $filename) {
207
+                $filepath = $filedir . $alias . '/' . $filename;
208
+                if($find === false && file_exists($filepath)) {
209
+                    $file = getFileContent($filepath);
210
+                    list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
211
+
212
+                    $date = filemtime($filepath);
213
+                    $field['pagetitle'] = $pagetitle;
214
+                    $field['longtitle'] = $pagetitle;
215
+                    $field['description'] = $description;
216
+                    $field['content'] = $modx->db->escape($content);
217
+                    $field['createdon'] = $date;
218
+                    $field['editedon'] = $date;
219
+                    $newid = $modx->db->insert($field, $tbl_site_content);
220
+                    if($newid) {
221
+                        $find = true;
222
+                        echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
223
+                        importFiles($newid, $filedir . $alias . '/', $value, 'sub');
224
+                    } else {
225
+                        echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
226
+                        exit;
227
+                    }
228
+                }
229
+            }
230
+            if($find === false) {
231
+                $date = time();
232
+                $field['pagetitle'] = '---';
233
+                $field['content'] = '';
234
+                $field['createdon'] = $date;
235
+                $field['editedon'] = $date;
236
+                $field['hidemenu'] = '1';
237
+                $newid = $modx->db->insert($field, $tbl_site_content);
238
+                if($newid) {
239
+                    $find = true;
240
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
241
+                    importFiles($newid, $filedir . $alias . '/', $value, 'sub');
242
+                } else {
243
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
244
+                    exit;
245
+                }
246
+            }
247
+        } else {
248
+            // create document
249
+            if($mode == 'sub' && $value == 'index.html') {
250
+                continue;
251
+            }
252
+            $filename = $value;
253
+            $fparts = explode('.', $value);
254
+            $alias = $fparts[0];
255
+            $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
256
+            printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
257
+
258
+            if(!in_array($ext, $allowedfiles)) {
259
+                echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
260
+            } else {
261
+                $filepath = $filedir . $filename;
262
+                $file = getFileContent($filepath);
263
+                list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
264
+
265
+                $date = filemtime($filepath);
266
+                $field = array();
267
+                $field['type'] = 'document';
268
+                $field['contentType'] = 'text/html';
269
+                $field['pagetitle'] = $pagetitle;
270
+                $field['longtitle'] = $pagetitle;
271
+                $field['description'] = $description;
272
+                $field['alias'] = $modx->stripAlias($alias);
273
+                $field['published'] = $publish_default;
274
+                $field['parent'] = $parent;
275
+                $field['content'] = $modx->db->escape($content);
276
+                $field['richtext'] = $richtext;
277
+                $field['template'] = $modx->config['default_template'];
278
+                $field['searchable'] = $search_default;
279
+                $field['cacheable'] = $cache_default;
280
+                $field['createdby'] = $createdby;
281
+                $field['createdon'] = $date;
282
+                $field['editedon'] = $date;
283
+                $field['isfolder'] = 0;
284
+                $field['menuindex'] = ($alias == 'index') ? 0 : 2;
285
+                $newid = $modx->db->insert($field, $tbl_site_content);
286
+                if($newid) {
287
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
288
+                } else {
289
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
290
+                    exit;
291
+                }
292
+
293
+                $is_site_start = false;
294
+                if($filename == 'index.html') {
295
+                    $is_site_start = true;
296
+                }
297
+                if($is_site_start == true && $_POST['reset'] == 'on') {
298
+                    $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
299
+                    $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
300
+                }
301
+            }
302
+        }
303
+    }
304 304
 }
305 305
 
306 306
 function getFiles($directory, $listing = array(), $count = 0) {
307
-	global $_lang;
308
-	global $filesfound;
309
-	$dummy = $count;
310
-	if( ! empty($directory) && $files = scandir($directory)) {
311
-		foreach($files as $file) {
312
-			if($file == '.' || $file == '..') {
313
-				continue;
314
-			} elseif($h = @opendir($directory . $file . "/")) {
315
-				closedir($h);
316
-				$count = -1;
317
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
318
-			} elseif(strpos($file, '.htm') !== false) {
319
-				$listing[$dummy] = $file;
320
-				$dummy = $dummy + 1;
321
-				$filesfound++;
322
-			}
323
-		}
324
-	} else {
325
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
326
-	}
327
-	return ($listing);
307
+    global $_lang;
308
+    global $filesfound;
309
+    $dummy = $count;
310
+    if( ! empty($directory) && $files = scandir($directory)) {
311
+        foreach($files as $file) {
312
+            if($file == '.' || $file == '..') {
313
+                continue;
314
+            } elseif($h = @opendir($directory . $file . "/")) {
315
+                closedir($h);
316
+                $count = -1;
317
+                $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
318
+            } elseif(strpos($file, '.htm') !== false) {
319
+                $listing[$dummy] = $file;
320
+                $dummy = $dummy + 1;
321
+                $filesfound++;
322
+            }
323
+        }
324
+    } else {
325
+        echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
326
+    }
327
+    return ($listing);
328 328
 }
329 329
 
330 330
 function getFileContent($filepath) {
331
-	global $_lang;
332
-	// get the file
333
-	if(!$buffer = file_get_contents($filepath)) {
334
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
335
-	} else {
336
-		return $buffer;
337
-	}
331
+    global $_lang;
332
+    // get the file
333
+    if(!$buffer = file_get_contents($filepath)) {
334
+        echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
335
+    } else {
336
+        return $buffer;
337
+    }
338 338
 }
339 339
 
340 340
 function pop_index($array) {
341
-	$new_array = array();
342
-	foreach($array as $k => $v) {
343
-		if($v !== 'index.html' && $v !== 'index.htm') {
344
-			$new_array[$k] = $v;
345
-		} else {
346
-			array_unshift($new_array, $v);
347
-		}
348
-	}
349
-	foreach($array as $k => $v) {
350
-		if(is_array($v)) {
351
-			$new_array[$k] = $v;
352
-		}
353
-	}
354
-	return $new_array;
341
+    $new_array = array();
342
+    foreach($array as $k => $v) {
343
+        if($v !== 'index.html' && $v !== 'index.htm') {
344
+            $new_array[$k] = $v;
345
+        } else {
346
+            array_unshift($new_array, $v);
347
+        }
348
+    }
349
+    foreach($array as $k => $v) {
350
+        if(is_array($v)) {
351
+            $new_array[$k] = $v;
352
+        }
353
+    }
354
+    return $new_array;
355 355
 }
356 356
 
357 357
 function treatContent($src, $filename, $alias) {
358
-	global $modx;
359
-
360
-	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
361
-
362
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
363
-		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
364
-		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
365
-	} else {
366
-		$pagetitle = $alias;
367
-	}
368
-	if(!$pagetitle) {
369
-		$pagetitle = $alias;
370
-	}
371
-
372
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
373
-		$description = ($matches[1] !== '') ? $matches[1] : $filename;
374
-		$description = str_replace('[*description*]', '', $description);
375
-	} else {
376
-		$description = '';
377
-	}
378
-
379
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
380
-		$content = $matches[1];
381
-	} else {
382
-		$content = $src;
383
-		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
384
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
385
-		$content = preg_replace($s, $r, $content);
386
-		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
387
-	}
388
-	$content = str_replace('[*content*]', '[ *content* ]', $content);
389
-	$content = trim($content);
390
-	$pagetitle = $modx->db->escape($pagetitle);
391
-	return array(
392
-		$pagetitle,
393
-		$content,
394
-		$description
395
-	);
358
+    global $modx;
359
+
360
+    $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
361
+
362
+    if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
363
+        $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
364
+        $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
365
+    } else {
366
+        $pagetitle = $alias;
367
+    }
368
+    if(!$pagetitle) {
369
+        $pagetitle = $alias;
370
+    }
371
+
372
+    if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
373
+        $description = ($matches[1] !== '') ? $matches[1] : $filename;
374
+        $description = str_replace('[*description*]', '', $description);
375
+    } else {
376
+        $description = '';
377
+    }
378
+
379
+    if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
380
+        $content = $matches[1];
381
+    } else {
382
+        $content = $src;
383
+        $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
384
+        $r = '$1' . $modx->config['modx_charset'] . '$2';
385
+        $content = preg_replace($s, $r, $content);
386
+        $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
387
+    }
388
+    $content = str_replace('[*content*]', '[ *content* ]', $content);
389
+    $content = trim($content);
390
+    $pagetitle = $modx->db->escape($pagetitle);
391
+    return array(
392
+        $pagetitle,
393
+        $content,
394
+        $description
395
+    );
396 396
 }
397 397
 
398 398
 function convertLink() {
399
-	global $modx;
400
-	$tbl_site_content = $modx->getFullTableName('site_content');
399
+    global $modx;
400
+    $tbl_site_content = $modx->getFullTableName('site_content');
401 401
 
402
-	$rs = $modx->db->select('id,content', $tbl_site_content);
403
-	$p = array();
402
+    $rs = $modx->db->select('id,content', $tbl_site_content);
403
+    $p = array();
404 404
     $target = array();
405
-	$dir = '';
406
-	while($row = $modx->db->getRow($rs)) {
407
-		$id = $row['id'];
408
-		$array = explode('<a href=', $row['content']);
409
-		$c = 0;
410
-		foreach($array as $v) {
411
-			if($v[0] === '"') {
412
-				$v = substr($v, 1);
413
-				list($href, $v) = explode('"', $v, 2);
414
-				$_ = $href;
415
-				if(strpos($_, $modx->config['site_url']) !== false) {
416
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
417
-				}
418
-				if($_[0] === '/') {
419
-					$_ = substr($_, 1);
420
-				}
421
-				$_ = str_replace('/index.html', '.html', $_);
422
-				$level = substr_count($_, '../');
423
-				if(1 < $level) {
424
-					if(!isset($p[$id])) {
425
-						$p[$id] = $modx->getParentIds($id);
426
-					}
427
-					$k = array_keys($p[$id]);
428
-					while(0 < $level) {
429
-						$dir = array_shift($k);
430
-						$level--;
431
-					}
432
-					if($dir != '') {
433
-						$dir .= '/';
434
-					}
435
-				} else {
436
-					$dir = '';
437
-				}
438
-
439
-				$_ = trim($_, './');
440
-				if(strpos($_, '/') !== false) {
441
-					$_ = substr($_, strrpos($_, '/'));
442
-				}
443
-				$_ = $dir . str_replace('.html', '', $_);
444
-				if(!isset($target[$_])) {
445
-					$target[$_] = $modx->getIdFromAlias($_);
446
-				}
447
-				$target[$_] = trim($target[$_]);
448
-				if(!empty($target[$_])) {
449
-					$href = '[~' . $target[$_] . '~]';
450
-				}
451
-				$array[$c] = '<a href="' . $href . '"' . $v;
452
-			}
453
-			$c++;
454
-		}
455
-		$content = implode('', $array);
456
-		$f['content'] = $modx->db->escape($content);
457
-		$modx->db->update($f, $tbl_site_content, "id='{$id}'");
458
-	}
405
+    $dir = '';
406
+    while($row = $modx->db->getRow($rs)) {
407
+        $id = $row['id'];
408
+        $array = explode('<a href=', $row['content']);
409
+        $c = 0;
410
+        foreach($array as $v) {
411
+            if($v[0] === '"') {
412
+                $v = substr($v, 1);
413
+                list($href, $v) = explode('"', $v, 2);
414
+                $_ = $href;
415
+                if(strpos($_, $modx->config['site_url']) !== false) {
416
+                    $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
417
+                }
418
+                if($_[0] === '/') {
419
+                    $_ = substr($_, 1);
420
+                }
421
+                $_ = str_replace('/index.html', '.html', $_);
422
+                $level = substr_count($_, '../');
423
+                if(1 < $level) {
424
+                    if(!isset($p[$id])) {
425
+                        $p[$id] = $modx->getParentIds($id);
426
+                    }
427
+                    $k = array_keys($p[$id]);
428
+                    while(0 < $level) {
429
+                        $dir = array_shift($k);
430
+                        $level--;
431
+                    }
432
+                    if($dir != '') {
433
+                        $dir .= '/';
434
+                    }
435
+                } else {
436
+                    $dir = '';
437
+                }
438
+
439
+                $_ = trim($_, './');
440
+                if(strpos($_, '/') !== false) {
441
+                    $_ = substr($_, strrpos($_, '/'));
442
+                }
443
+                $_ = $dir . str_replace('.html', '', $_);
444
+                if(!isset($target[$_])) {
445
+                    $target[$_] = $modx->getIdFromAlias($_);
446
+                }
447
+                $target[$_] = trim($target[$_]);
448
+                if(!empty($target[$_])) {
449
+                    $href = '[~' . $target[$_] . '~]';
450
+                }
451
+                $array[$c] = '<a href="' . $href . '"' . $v;
452
+            }
453
+            $c++;
454
+        }
455
+        $content = implode('', $array);
456
+        $f['content'] = $modx->db->escape($content);
457
+        $modx->db->update($f, $tbl_site_content, "id='{$id}'");
458
+    }
459 459
 }
Please login to merge, or discard this patch.
manager/frames/nodes.functions.inc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -504,6 +504,9 @@
 block discarded – undo
504 504
 	return $iconsPrivate;
505 505
 }
506 506
 
507
+/**
508
+ * @return string
509
+ */
507 510
 function getNodeTitle($nodeNameSource, $row) {
508 511
 	global $modx;
509 512
 
Please login to merge, or discard this patch.
Indentation   +553 added lines, -553 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
3
+    die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
4 4
 }
5 5
 
6 6
 /**
@@ -11,575 +11,575 @@  discard block
 block discarded – undo
11 11
  * @param string $hereid
12 12
  */
13 13
 function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') {
14
-	global $modx;
15
-	global $icons, $iconsPrivate, $_style;
16
-	global $_lang, $opened, $opened2, $closed2; //added global vars
17
-	global $modx_textdir;
18
-
19
-	$output = '';
20
-
21
-	// setup spacer
22
-	$level = 0;
23
-	$spacer = '<span class="indent">';
24
-	for($i = 2; $i <= $indent; $i++) {
25
-		$spacer .= '<i></i>';
26
-		$level++;
27
-	}
28
-	$spacer .= '</span>';
29
-
30
-	// manage order-by
31
-	if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
32
-		// This is the first startup, set default sort order
33
-		$_SESSION['tree_sortby'] = 'menuindex';
34
-		$_SESSION['tree_sortdir'] = 'ASC';
35
-	}
36
-
37
-	switch($_SESSION['tree_sortby']) {
38
-		case 'createdon':
39
-		case 'editedon':
40
-		case 'publishedon':
41
-		case 'pub_date':
42
-		case 'unpub_date':
43
-			$sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']);
44
-			break;
45
-		default:
46
-			$sortby = 'sc.' . $_SESSION['tree_sortby'];
47
-	};
48
-
49
-	$orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']);
50
-
51
-	// Folder sorting gets special setup ;) Add menuindex and pagetitle
52
-	if($_SESSION['tree_sortby'] == 'isfolder') {
53
-		$orderby .= ', menuindex ASC, pagetitle';
54
-	}
55
-
56
-	$tblsc = $modx->getFullTableName('site_content');
57
-	$tbldg = $modx->getFullTableName('document_groups');
58
-	$tblst = $modx->getFullTableName('site_templates');
59
-	// get document groups for current user
60
-	$docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
61
-	$showProtected = false;
62
-	if(isset ($modx->config['tree_show_protected'])) {
63
-		$showProtected = (boolean) $modx->config['tree_show_protected'];
64
-	}
65
-	$mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0';
66
-	if($showProtected == false) {
67
-		$access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
68
-	} else {
69
-		$access = '';
70
-	}
71
-	$docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : '';
72
-	$field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr,
14
+    global $modx;
15
+    global $icons, $iconsPrivate, $_style;
16
+    global $_lang, $opened, $opened2, $closed2; //added global vars
17
+    global $modx_textdir;
18
+
19
+    $output = '';
20
+
21
+    // setup spacer
22
+    $level = 0;
23
+    $spacer = '<span class="indent">';
24
+    for($i = 2; $i <= $indent; $i++) {
25
+        $spacer .= '<i></i>';
26
+        $level++;
27
+    }
28
+    $spacer .= '</span>';
29
+
30
+    // manage order-by
31
+    if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
32
+        // This is the first startup, set default sort order
33
+        $_SESSION['tree_sortby'] = 'menuindex';
34
+        $_SESSION['tree_sortdir'] = 'ASC';
35
+    }
36
+
37
+    switch($_SESSION['tree_sortby']) {
38
+        case 'createdon':
39
+        case 'editedon':
40
+        case 'publishedon':
41
+        case 'pub_date':
42
+        case 'unpub_date':
43
+            $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']);
44
+            break;
45
+        default:
46
+            $sortby = 'sc.' . $_SESSION['tree_sortby'];
47
+    };
48
+
49
+    $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']);
50
+
51
+    // Folder sorting gets special setup ;) Add menuindex and pagetitle
52
+    if($_SESSION['tree_sortby'] == 'isfolder') {
53
+        $orderby .= ', menuindex ASC, pagetitle';
54
+    }
55
+
56
+    $tblsc = $modx->getFullTableName('site_content');
57
+    $tbldg = $modx->getFullTableName('document_groups');
58
+    $tblst = $modx->getFullTableName('site_templates');
59
+    // get document groups for current user
60
+    $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : '';
61
+    $showProtected = false;
62
+    if(isset ($modx->config['tree_show_protected'])) {
63
+        $showProtected = (boolean) $modx->config['tree_show_protected'];
64
+    }
65
+    $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0';
66
+    if($showProtected == false) {
67
+        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))");
68
+    } else {
69
+        $access = '';
70
+    }
71
+    $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : '';
72
+    $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr,
73 73
         MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles";
74
-	$from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template";
75
-	$where = "(parent={$parent}) {$access} GROUP BY sc.id";
76
-	$result = $modx->db->select($field, $from, $where, $orderby);
77
-	if($modx->db->getRecordCount($result) == 0) {
78
-		$output .= sprintf('<div><a class="empty">%s%s&nbsp;<span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']);
79
-	}
80
-
81
-	$nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename'];
82
-
83
-	while($row = $modx->db->getRow($result)) {
84
-		$node = '';
85
-
86
-		$nodetitle = getNodeTitle($nodeNameSource, $row);
87
-		$nodetitleDisplay = $nodetitle;
88
-
89
-		$treeNodeClass = 'node';
90
-		$treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : '';
91
-
92
-		if($row['deleted'] == 1) {
93
-			$treeNodeClass .= ' deleted';
94
-			//$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle);
95
-		} elseif($row['published'] == 0) {
96
-			$treeNodeClass .= ' unpublished';
97
-			//$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle);
98
-		} elseif($row['hidemenu'] == 1) {
99
-			$treeNodeClass .= ' hidemenu';
100
-			//$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle);
101
-		} else {
102
-			//$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle);
103
-		}
104
-
105
-		if($row['id'] == $hereid) {
106
-			$treeNodeClass .= ' current';
107
-		}
108
-
109
-		$weblinkDisplay = $row['type'] == 'reference' ? sprintf('&nbsp;%s', $_style['tree_linkgo']) : '';
110
-		$pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $row['id'] . ')</small>';
111
-
112
-		// Prepare displaying user-locks
113
-		$lockedByUser = '';
114
-		$rowLock = $modx->elementIsLocked(7, $row['id'], true);
115
-		if($rowLock && $modx->hasPermission('display_locks')) {
116
-			if($rowLock['sid'] == $modx->sid) {
117
-				$title = $modx->parseText($_lang["lock_element_editing"], array(
118
-					'element_type' => $_lang["lock_element_type_7"],
119
-					'lasthit_df' => $rowLock['lasthit_df']
120
-				));
121
-				$lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>';
122
-			} else {
123
-				$title = $modx->parseText($_lang["lock_element_locked_by"], array(
124
-					'element_type' => $_lang["lock_element_type_7"],
125
-					'username' => $rowLock['username'],
126
-					'lasthit_df' => $rowLock['lasthit_df']
127
-				));
128
-				if($modx->hasPermission('remove_locks')) {
129
-					$lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
130
-				} else {
131
-					$lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
132
-				}
133
-			}
134
-		}
135
-
136
-		$url = $modx->makeUrl($row['id']);
137
-
138
-		$title = '';
139
-		if(isDateNode($nodeNameSource)) {
140
-			$title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]';
141
-		}
142
-		$title .= $_lang['id'] . ': ' . $row['id'];
143
-		$title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle'];
144
-		$title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex'];
145
-		$title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-');
146
-		$title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename'];
147
-		$title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']);
148
-		$title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']);
149
-		$title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']);
150
-		$title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
151
-		$title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
152
-		$title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
153
-		$title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
154
-		$title = $modx->htmlspecialchars($title);
155
-		$title = str_replace('[+lf+]', ' &#13;', $title);   // replace line-breaks with empty space as fall-back
156
-
157
-		$data = array(
158
-			'id' => $row['id'],
159
-			'pagetitle' => $row['pagetitle'],
160
-			'longtitle' => $row['longtitle'],
161
-			'menutitle' => $row['menutitle'],
162
-			'parent' => $parent,
163
-			'isfolder' => $row['isfolder'],
164
-			'published' => $row['published'],
165
-			'deleted' => $row['deleted'],
166
-			'type' => $row['type'],
167
-			'menuindex' => $row['menuindex'],
168
-			'donthit' => $row['donthit'],
169
-			'hidemenu' => $row['hidemenu'],
170
-			'alias' => $row['alias'],
171
-			'contenttype' => $row['contentType'],
172
-			'privateweb' => $row['privateweb'],
173
-			'privatemgr' => $row['privatemgr'],
174
-			'hasAccess' => $row['hasAccess'],
175
-			'template' => $row['template'],
176
-			'nodetitle' => $nodetitle,
177
-			'url' => $url,
178
-			'title' => $title,
179
-			'nodetitleDisplay' => $nodetitleDisplay,
180
-			'weblinkDisplay' => $weblinkDisplay,
181
-			'pageIdDisplay' => $pageIdDisplay,
182
-			'lockedByUser' => $lockedByUser,
183
-			'treeNodeClass' => $treeNodeClass,
184
-			'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '',
185
-			'tree_page_click' => $modx->config['tree_page_click'],
186
-			'showChildren' => 1,
187
-			'openFolder' => 1,
188
-			'contextmenu' => '',
189
-			'tree_minusnode' => $_style['tree_minusnode'],
190
-			'tree_plusnode' => $_style['tree_plusnode'],
191
-			'spacer' => $spacer,
192
-			'subMenuState' => '',
193
-			'level' => $level,
194
-			'isPrivate' => 0,
195
-			'roles' => ($row['roles'] ? $row['roles'] : '')
196
-		);
197
-
198
-		$ph = $data;
199
-		$ph['nodetitle_esc'] = addslashes($nodetitle);
200
-		$ph['indent'] = $indent + 1;
201
-		$ph['expandAll'] = $expandAll;
202
-		$ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0;
203
-
204
-		if(!$row['isfolder']) {
205
-			$tpl = getTplSingleNode();
206
-			switch($row['id']) {
207
-				case $modx->config['site_start']            :
208
-					$icon = $_style['tree_page_home'];
209
-					break;
210
-				case $modx->config['error_page']            :
211
-					$icon = $_style['tree_page_404'];
212
-					break;
213
-				case $modx->config['site_unavailable_page'] :
214
-					$icon = $_style['tree_page_hourglass'];
215
-					break;
216
-				case $modx->config['unauthorized_page']     :
217
-					$icon = $_style['tree_page_info'];
218
-					break;
219
-				default:
220
-					if(isset($icons[$row['contentType']])) {
221
-						$icon = $icons[$row['contentType']];
222
-					} else {
223
-						$icon = $_style['tree_page'];
224
-					}
225
-			}
226
-			$ph['icon'] = $icon;
227
-
228
-			// invoke OnManagerNodePrerender event
229
-			$prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph));
230
-			if(is_array($prenode)) {
231
-				$phnew = array();
232
-				foreach($prenode as $pnode) {
233
-					$phnew = array_merge($phnew, unserialize($pnode));
234
-				}
235
-				$ph = (count($phnew) > 0) ? $phnew : $ph;
236
-			}
237
-
238
-			if($ph['contextmenu']) {
239
-				$ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
240
-			}
241
-
242
-			if($_SESSION['tree_show_only_folders']) {
243
-				if($row['parent'] == 0) {
244
-					$node .= $modx->parseText($tpl, $ph);
245
-				} else {
246
-					$node .= '';
247
-				}
248
-			} else {
249
-				$node .= $modx->parseText($tpl, $ph);
250
-			}
251
-
252
-		} else {
253
-			$ph['icon_folder_open'] = $_style['tree_folderopen_new'];
254
-			$ph['icon_folder_close'] = $_style['tree_folder_new'];
255
-
256
-			if($_SESSION['tree_show_only_folders']) {
257
-				$tpl = getTplFolderNodeNotChildren();
258
-				$checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders
259
-				$checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders
260
-				$ph['tree_page_click'] = 3;
261
-
262
-				// expandAll: two type for partial expansion
263
-				if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) {
264
-					if($expandAll == 1) {
265
-						$opened2[] = $row['id'];
266
-					}
267
-					$ph['icon'] = $ph['icon_folder_open'];
268
-					$ph['icon_node_toggle'] = $ph['tree_minusnode'];
269
-					$ph['node_toggle'] = 1;
270
-					$ph['subMenuState'] = ' open';
271
-
272
-					if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) {
273
-						$ph['showChildren'] = 1;
274
-						$ph['icon_node_toggle'] = '';
275
-						$ph['icon'] = $ph['icon_folder_close'];
276
-					} elseif(!$checkDocs && $checkFolders) {
277
-						$ph['showChildren'] = 0;
278
-						$ph['openFolder'] = 2;
279
-					} else {
280
-						$ph['openFolder'] = 2;
281
-					}
282
-
283
-					// invoke OnManagerNodePrerender event
284
-					$prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
285
-						'ph' => $ph,
286
-						'opened' => '1'
287
-					));
288
-					if(is_array($prenode)) {
289
-						$phnew = array();
290
-						foreach($prenode as $pnode) {
291
-							$phnew = array_merge($phnew, unserialize($pnode));
292
-						}
293
-						$ph = (count($phnew) > 0) ? $phnew : $ph;
294
-					}
295
-
296
-					if($ph['contextmenu']) {
297
-						$ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
298
-					}
299
-
300
-					$node .= $modx->parseText($tpl, $ph);
301
-					if($checkFolders) {
302
-						$node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid);
303
-					}
304
-					$node .= '</div></div>';
305
-				} else {
306
-					$closed2[] = $row['id'];
307
-					$ph['icon'] = $ph['icon_folder_close'];
308
-					$ph['icon_node_toggle'] = $ph['tree_plusnode'];
309
-					$ph['node_toggle'] = 0;
310
-
311
-					if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) {
312
-						$ph['showChildren'] = 1;
313
-						$ph['icon_node_toggle'] = '';
314
-					} elseif(!$checkDocs && $checkFolders) {
315
-						$ph['showChildren'] = 0;
316
-						$ph['openFolder'] = 2;
317
-					} else {
318
-						$ph['openFolder'] = 2;
319
-					}
320
-
321
-					// invoke OnManagerNodePrerender event
322
-					$prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
323
-						'ph' => $ph,
324
-						'opened' => '0'
325
-					));
326
-					if(is_array($prenode)) {
327
-						$phnew = array();
328
-						foreach($prenode as $pnode) {
329
-							$phnew = array_merge($phnew, unserialize($pnode));
330
-						}
331
-						$ph = (count($phnew) > 0) ? $phnew : $ph;
332
-					}
333
-
334
-					if($ph['contextmenu']) {
335
-						$ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
336
-					}
337
-
338
-					$node .= $modx->parseText($tpl, $ph);
339
-					$node .= '</div></div>';
340
-				}
341
-			} else {
342
-				$tpl = getTplFolderNode();
343
-				// expandAll: two type for partial expansion
344
-				if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) {
345
-					if($expandAll == 1) {
346
-						$opened2[] = $row['id'];
347
-					}
348
-					$ph['icon'] = $ph['icon_folder_open'];
349
-					$ph['icon_node_toggle'] = $ph['tree_minusnode'];
350
-					$ph['node_toggle'] = 1;
351
-					$ph['subMenuState'] = ' open';
352
-
353
-					if($ph['donthit'] == 1) {
354
-						$ph['tree_page_click'] = 3;
355
-						$ph['icon_node_toggle'] = '';
356
-						$ph['icon'] = $ph['icon_folder_close'];
357
-						$ph['showChildren'] = 0;
358
-					}
359
-
360
-					// invoke OnManagerNodePrerender event
361
-					$prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
362
-						'ph' => $ph,
363
-						'opened' => '1'
364
-					));
365
-					if(is_array($prenode)) {
366
-						$phnew = array();
367
-						foreach($prenode as $pnode) {
368
-							$phnew = array_merge($phnew, unserialize($pnode));
369
-						}
370
-						$ph = (count($phnew) > 0) ? $phnew : $ph;
371
-						if($ph['showChildren'] == 0) {
372
-							unset($opened2[$row['id']]);
373
-							$ph['node_toggle'] = 0;
374
-							$ph['subMenuState'] = '';
375
-						}
376
-					}
377
-
378
-					if($ph['showChildren'] == 0) {
379
-						$ph['icon_node_toggle'] = '';
380
-						$ph['donthit'] = 1;
381
-						$ph['icon'] = $ph['icon_folder_close'];
382
-						$tpl = getTplFolderNodeNotChildren();
383
-					}
384
-
385
-					if($ph['contextmenu']) {
386
-						$ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
387
-					}
388
-
389
-					$node .= $modx->parseText($tpl, $ph);
390
-					if($ph['donthit'] == 0) {
391
-						$node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid);
392
-					}
393
-					$node .= '</div></div>';
394
-				} else {
395
-					$closed2[] = $row['id'];
396
-					$ph['icon'] = $ph['icon_folder_close'];
397
-					$ph['icon_node_toggle'] = $ph['tree_plusnode'];
398
-					$ph['node_toggle'] = 0;
399
-
400
-					if($ph['donthit'] == 1) {
401
-						$ph['tree_page_click'] = 3;
402
-						$ph['icon_node_toggle'] = '';
403
-						$ph['icon'] = $ph['icon_folder_close'];
404
-						$ph['showChildren'] = 0;
405
-					}
406
-
407
-					// invoke OnManagerNodePrerender event
408
-					$prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
409
-						'ph' => $ph,
410
-						'opened' => '0'
411
-					));
412
-					if(is_array($prenode)) {
413
-						$phnew = array();
414
-						foreach($prenode as $pnode) {
415
-							$phnew = array_merge($phnew, unserialize($pnode));
416
-						}
417
-						$ph = (count($phnew) > 0) ? $phnew : $ph;
418
-					}
419
-
420
-					if($ph['showChildren'] == 0) {
421
-						$ph['icon_node_toggle'] = '';
422
-						$ph['donthit'] = 1;
423
-						$ph['icon'] = $ph['icon_folder_close'];
424
-						$tpl = getTplFolderNodeNotChildren();
425
-					}
426
-
427
-					if($ph['contextmenu']) {
428
-						$ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
429
-					}
430
-
431
-					$node .= $modx->parseText($tpl, $ph);
432
-					$node .= '</div></div>';
433
-				}
434
-			}
435
-		}
436
-
437
-		// invoke OnManagerNodeRender event
438
-		$data['node'] = $node;
439
-		$evtOut = $modx->invokeEvent('OnManagerNodeRender', $data);
440
-		if(is_array($evtOut)) {
441
-			$evtOut = implode("\n", $evtOut);
442
-		}
443
-		if($evtOut != '') {
444
-			$node = trim($evtOut);
445
-		}
446
-
447
-		$output .= $node;
448
-	}
449
-
450
-	return $output;
74
+    $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template";
75
+    $where = "(parent={$parent}) {$access} GROUP BY sc.id";
76
+    $result = $modx->db->select($field, $from, $where, $orderby);
77
+    if($modx->db->getRecordCount($result) == 0) {
78
+        $output .= sprintf('<div><a class="empty">%s%s&nbsp;<span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']);
79
+    }
80
+
81
+    $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename'];
82
+
83
+    while($row = $modx->db->getRow($result)) {
84
+        $node = '';
85
+
86
+        $nodetitle = getNodeTitle($nodeNameSource, $row);
87
+        $nodetitleDisplay = $nodetitle;
88
+
89
+        $treeNodeClass = 'node';
90
+        $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : '';
91
+
92
+        if($row['deleted'] == 1) {
93
+            $treeNodeClass .= ' deleted';
94
+            //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle);
95
+        } elseif($row['published'] == 0) {
96
+            $treeNodeClass .= ' unpublished';
97
+            //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle);
98
+        } elseif($row['hidemenu'] == 1) {
99
+            $treeNodeClass .= ' hidemenu';
100
+            //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle);
101
+        } else {
102
+            //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle);
103
+        }
104
+
105
+        if($row['id'] == $hereid) {
106
+            $treeNodeClass .= ' current';
107
+        }
108
+
109
+        $weblinkDisplay = $row['type'] == 'reference' ? sprintf('&nbsp;%s', $_style['tree_linkgo']) : '';
110
+        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $row['id'] . ')</small>';
111
+
112
+        // Prepare displaying user-locks
113
+        $lockedByUser = '';
114
+        $rowLock = $modx->elementIsLocked(7, $row['id'], true);
115
+        if($rowLock && $modx->hasPermission('display_locks')) {
116
+            if($rowLock['sid'] == $modx->sid) {
117
+                $title = $modx->parseText($_lang["lock_element_editing"], array(
118
+                    'element_type' => $_lang["lock_element_type_7"],
119
+                    'lasthit_df' => $rowLock['lasthit_df']
120
+                ));
121
+                $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>';
122
+            } else {
123
+                $title = $modx->parseText($_lang["lock_element_locked_by"], array(
124
+                    'element_type' => $_lang["lock_element_type_7"],
125
+                    'username' => $rowLock['username'],
126
+                    'lasthit_df' => $rowLock['lasthit_df']
127
+                ));
128
+                if($modx->hasPermission('remove_locks')) {
129
+                    $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
130
+                } else {
131
+                    $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>';
132
+                }
133
+            }
134
+        }
135
+
136
+        $url = $modx->makeUrl($row['id']);
137
+
138
+        $title = '';
139
+        if(isDateNode($nodeNameSource)) {
140
+            $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]';
141
+        }
142
+        $title .= $_lang['id'] . ': ' . $row['id'];
143
+        $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle'];
144
+        $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex'];
145
+        $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-');
146
+        $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename'];
147
+        $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']);
148
+        $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']);
149
+        $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']);
150
+        $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']);
151
+        $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']);
152
+        $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']);
153
+        $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']);
154
+        $title = $modx->htmlspecialchars($title);
155
+        $title = str_replace('[+lf+]', ' &#13;', $title);   // replace line-breaks with empty space as fall-back
156
+
157
+        $data = array(
158
+            'id' => $row['id'],
159
+            'pagetitle' => $row['pagetitle'],
160
+            'longtitle' => $row['longtitle'],
161
+            'menutitle' => $row['menutitle'],
162
+            'parent' => $parent,
163
+            'isfolder' => $row['isfolder'],
164
+            'published' => $row['published'],
165
+            'deleted' => $row['deleted'],
166
+            'type' => $row['type'],
167
+            'menuindex' => $row['menuindex'],
168
+            'donthit' => $row['donthit'],
169
+            'hidemenu' => $row['hidemenu'],
170
+            'alias' => $row['alias'],
171
+            'contenttype' => $row['contentType'],
172
+            'privateweb' => $row['privateweb'],
173
+            'privatemgr' => $row['privatemgr'],
174
+            'hasAccess' => $row['hasAccess'],
175
+            'template' => $row['template'],
176
+            'nodetitle' => $nodetitle,
177
+            'url' => $url,
178
+            'title' => $title,
179
+            'nodetitleDisplay' => $nodetitleDisplay,
180
+            'weblinkDisplay' => $weblinkDisplay,
181
+            'pageIdDisplay' => $pageIdDisplay,
182
+            'lockedByUser' => $lockedByUser,
183
+            'treeNodeClass' => $treeNodeClass,
184
+            'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '',
185
+            'tree_page_click' => $modx->config['tree_page_click'],
186
+            'showChildren' => 1,
187
+            'openFolder' => 1,
188
+            'contextmenu' => '',
189
+            'tree_minusnode' => $_style['tree_minusnode'],
190
+            'tree_plusnode' => $_style['tree_plusnode'],
191
+            'spacer' => $spacer,
192
+            'subMenuState' => '',
193
+            'level' => $level,
194
+            'isPrivate' => 0,
195
+            'roles' => ($row['roles'] ? $row['roles'] : '')
196
+        );
197
+
198
+        $ph = $data;
199
+        $ph['nodetitle_esc'] = addslashes($nodetitle);
200
+        $ph['indent'] = $indent + 1;
201
+        $ph['expandAll'] = $expandAll;
202
+        $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0;
203
+
204
+        if(!$row['isfolder']) {
205
+            $tpl = getTplSingleNode();
206
+            switch($row['id']) {
207
+                case $modx->config['site_start']            :
208
+                    $icon = $_style['tree_page_home'];
209
+                    break;
210
+                case $modx->config['error_page']            :
211
+                    $icon = $_style['tree_page_404'];
212
+                    break;
213
+                case $modx->config['site_unavailable_page'] :
214
+                    $icon = $_style['tree_page_hourglass'];
215
+                    break;
216
+                case $modx->config['unauthorized_page']     :
217
+                    $icon = $_style['tree_page_info'];
218
+                    break;
219
+                default:
220
+                    if(isset($icons[$row['contentType']])) {
221
+                        $icon = $icons[$row['contentType']];
222
+                    } else {
223
+                        $icon = $_style['tree_page'];
224
+                    }
225
+            }
226
+            $ph['icon'] = $icon;
227
+
228
+            // invoke OnManagerNodePrerender event
229
+            $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph));
230
+            if(is_array($prenode)) {
231
+                $phnew = array();
232
+                foreach($prenode as $pnode) {
233
+                    $phnew = array_merge($phnew, unserialize($pnode));
234
+                }
235
+                $ph = (count($phnew) > 0) ? $phnew : $ph;
236
+            }
237
+
238
+            if($ph['contextmenu']) {
239
+                $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
240
+            }
241
+
242
+            if($_SESSION['tree_show_only_folders']) {
243
+                if($row['parent'] == 0) {
244
+                    $node .= $modx->parseText($tpl, $ph);
245
+                } else {
246
+                    $node .= '';
247
+                }
248
+            } else {
249
+                $node .= $modx->parseText($tpl, $ph);
250
+            }
251
+
252
+        } else {
253
+            $ph['icon_folder_open'] = $_style['tree_folderopen_new'];
254
+            $ph['icon_folder_close'] = $_style['tree_folder_new'];
255
+
256
+            if($_SESSION['tree_show_only_folders']) {
257
+                $tpl = getTplFolderNodeNotChildren();
258
+                $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders
259
+                $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders
260
+                $ph['tree_page_click'] = 3;
261
+
262
+                // expandAll: two type for partial expansion
263
+                if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) {
264
+                    if($expandAll == 1) {
265
+                        $opened2[] = $row['id'];
266
+                    }
267
+                    $ph['icon'] = $ph['icon_folder_open'];
268
+                    $ph['icon_node_toggle'] = $ph['tree_minusnode'];
269
+                    $ph['node_toggle'] = 1;
270
+                    $ph['subMenuState'] = ' open';
271
+
272
+                    if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) {
273
+                        $ph['showChildren'] = 1;
274
+                        $ph['icon_node_toggle'] = '';
275
+                        $ph['icon'] = $ph['icon_folder_close'];
276
+                    } elseif(!$checkDocs && $checkFolders) {
277
+                        $ph['showChildren'] = 0;
278
+                        $ph['openFolder'] = 2;
279
+                    } else {
280
+                        $ph['openFolder'] = 2;
281
+                    }
282
+
283
+                    // invoke OnManagerNodePrerender event
284
+                    $prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
285
+                        'ph' => $ph,
286
+                        'opened' => '1'
287
+                    ));
288
+                    if(is_array($prenode)) {
289
+                        $phnew = array();
290
+                        foreach($prenode as $pnode) {
291
+                            $phnew = array_merge($phnew, unserialize($pnode));
292
+                        }
293
+                        $ph = (count($phnew) > 0) ? $phnew : $ph;
294
+                    }
295
+
296
+                    if($ph['contextmenu']) {
297
+                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
298
+                    }
299
+
300
+                    $node .= $modx->parseText($tpl, $ph);
301
+                    if($checkFolders) {
302
+                        $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid);
303
+                    }
304
+                    $node .= '</div></div>';
305
+                } else {
306
+                    $closed2[] = $row['id'];
307
+                    $ph['icon'] = $ph['icon_folder_close'];
308
+                    $ph['icon_node_toggle'] = $ph['tree_plusnode'];
309
+                    $ph['node_toggle'] = 0;
310
+
311
+                    if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) {
312
+                        $ph['showChildren'] = 1;
313
+                        $ph['icon_node_toggle'] = '';
314
+                    } elseif(!$checkDocs && $checkFolders) {
315
+                        $ph['showChildren'] = 0;
316
+                        $ph['openFolder'] = 2;
317
+                    } else {
318
+                        $ph['openFolder'] = 2;
319
+                    }
320
+
321
+                    // invoke OnManagerNodePrerender event
322
+                    $prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
323
+                        'ph' => $ph,
324
+                        'opened' => '0'
325
+                    ));
326
+                    if(is_array($prenode)) {
327
+                        $phnew = array();
328
+                        foreach($prenode as $pnode) {
329
+                            $phnew = array_merge($phnew, unserialize($pnode));
330
+                        }
331
+                        $ph = (count($phnew) > 0) ? $phnew : $ph;
332
+                    }
333
+
334
+                    if($ph['contextmenu']) {
335
+                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
336
+                    }
337
+
338
+                    $node .= $modx->parseText($tpl, $ph);
339
+                    $node .= '</div></div>';
340
+                }
341
+            } else {
342
+                $tpl = getTplFolderNode();
343
+                // expandAll: two type for partial expansion
344
+                if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) {
345
+                    if($expandAll == 1) {
346
+                        $opened2[] = $row['id'];
347
+                    }
348
+                    $ph['icon'] = $ph['icon_folder_open'];
349
+                    $ph['icon_node_toggle'] = $ph['tree_minusnode'];
350
+                    $ph['node_toggle'] = 1;
351
+                    $ph['subMenuState'] = ' open';
352
+
353
+                    if($ph['donthit'] == 1) {
354
+                        $ph['tree_page_click'] = 3;
355
+                        $ph['icon_node_toggle'] = '';
356
+                        $ph['icon'] = $ph['icon_folder_close'];
357
+                        $ph['showChildren'] = 0;
358
+                    }
359
+
360
+                    // invoke OnManagerNodePrerender event
361
+                    $prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
362
+                        'ph' => $ph,
363
+                        'opened' => '1'
364
+                    ));
365
+                    if(is_array($prenode)) {
366
+                        $phnew = array();
367
+                        foreach($prenode as $pnode) {
368
+                            $phnew = array_merge($phnew, unserialize($pnode));
369
+                        }
370
+                        $ph = (count($phnew) > 0) ? $phnew : $ph;
371
+                        if($ph['showChildren'] == 0) {
372
+                            unset($opened2[$row['id']]);
373
+                            $ph['node_toggle'] = 0;
374
+                            $ph['subMenuState'] = '';
375
+                        }
376
+                    }
377
+
378
+                    if($ph['showChildren'] == 0) {
379
+                        $ph['icon_node_toggle'] = '';
380
+                        $ph['donthit'] = 1;
381
+                        $ph['icon'] = $ph['icon_folder_close'];
382
+                        $tpl = getTplFolderNodeNotChildren();
383
+                    }
384
+
385
+                    if($ph['contextmenu']) {
386
+                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
387
+                    }
388
+
389
+                    $node .= $modx->parseText($tpl, $ph);
390
+                    if($ph['donthit'] == 0) {
391
+                        $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid);
392
+                    }
393
+                    $node .= '</div></div>';
394
+                } else {
395
+                    $closed2[] = $row['id'];
396
+                    $ph['icon'] = $ph['icon_folder_close'];
397
+                    $ph['icon_node_toggle'] = $ph['tree_plusnode'];
398
+                    $ph['node_toggle'] = 0;
399
+
400
+                    if($ph['donthit'] == 1) {
401
+                        $ph['tree_page_click'] = 3;
402
+                        $ph['icon_node_toggle'] = '';
403
+                        $ph['icon'] = $ph['icon_folder_close'];
404
+                        $ph['showChildren'] = 0;
405
+                    }
406
+
407
+                    // invoke OnManagerNodePrerender event
408
+                    $prenode = $modx->invokeEvent("OnManagerNodePrerender", array(
409
+                        'ph' => $ph,
410
+                        'opened' => '0'
411
+                    ));
412
+                    if(is_array($prenode)) {
413
+                        $phnew = array();
414
+                        foreach($prenode as $pnode) {
415
+                            $phnew = array_merge($phnew, unserialize($pnode));
416
+                        }
417
+                        $ph = (count($phnew) > 0) ? $phnew : $ph;
418
+                    }
419
+
420
+                    if($ph['showChildren'] == 0) {
421
+                        $ph['icon_node_toggle'] = '';
422
+                        $ph['donthit'] = 1;
423
+                        $ph['icon'] = $ph['icon_folder_close'];
424
+                        $tpl = getTplFolderNodeNotChildren();
425
+                    }
426
+
427
+                    if($ph['contextmenu']) {
428
+                        $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"';
429
+                    }
430
+
431
+                    $node .= $modx->parseText($tpl, $ph);
432
+                    $node .= '</div></div>';
433
+                }
434
+            }
435
+        }
436
+
437
+        // invoke OnManagerNodeRender event
438
+        $data['node'] = $node;
439
+        $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data);
440
+        if(is_array($evtOut)) {
441
+            $evtOut = implode("\n", $evtOut);
442
+        }
443
+        if($evtOut != '') {
444
+            $node = trim($evtOut);
445
+        }
446
+
447
+        $output .= $node;
448
+    }
449
+
450
+    return $output;
451 451
 }
452 452
 
453 453
 function getIconInfo($_style) {
454
-	if(!isset($_style['tree_page_gif'])) {
455
-		$_style['tree_page_gif'] = $_style['tree_page'];
456
-	}
457
-	if(!isset($_style['tree_page_jpg'])) {
458
-		$_style['tree_page_jpg'] = $_style['tree_page'];
459
-	}
460
-	if(!isset($_style['tree_page_png'])) {
461
-		$_style['tree_page_png'] = $_style['tree_page'];
462
-	}
463
-	$icons = array(
464
-		'text/html' => $_style['tree_page_html'],
465
-		'text/plain' => $_style['tree_page'],
466
-		'text/xml' => $_style['tree_page_xml'],
467
-		'text/css' => $_style['tree_page_css'],
468
-		'text/javascript' => $_style['tree_page_js'],
469
-		'application/rss+xml' => $_style['tree_page_rss'],
470
-		'application/pdf' => $_style['tree_page_pdf'],
471
-		'application/vnd.ms-word' => $_style['tree_page_word'],
472
-		'application/vnd.ms-excel' => $_style['tree_page_excel'],
473
-		'image/gif' => $_style['tree_page_gif'],
474
-		'image/jpg' => $_style['tree_page_jpg'],
475
-		'image/png' => $_style['tree_page_png']
476
-	);
477
-	return $icons;
454
+    if(!isset($_style['tree_page_gif'])) {
455
+        $_style['tree_page_gif'] = $_style['tree_page'];
456
+    }
457
+    if(!isset($_style['tree_page_jpg'])) {
458
+        $_style['tree_page_jpg'] = $_style['tree_page'];
459
+    }
460
+    if(!isset($_style['tree_page_png'])) {
461
+        $_style['tree_page_png'] = $_style['tree_page'];
462
+    }
463
+    $icons = array(
464
+        'text/html' => $_style['tree_page_html'],
465
+        'text/plain' => $_style['tree_page'],
466
+        'text/xml' => $_style['tree_page_xml'],
467
+        'text/css' => $_style['tree_page_css'],
468
+        'text/javascript' => $_style['tree_page_js'],
469
+        'application/rss+xml' => $_style['tree_page_rss'],
470
+        'application/pdf' => $_style['tree_page_pdf'],
471
+        'application/vnd.ms-word' => $_style['tree_page_word'],
472
+        'application/vnd.ms-excel' => $_style['tree_page_excel'],
473
+        'image/gif' => $_style['tree_page_gif'],
474
+        'image/jpg' => $_style['tree_page_jpg'],
475
+        'image/png' => $_style['tree_page_png']
476
+    );
477
+    return $icons;
478 478
 }
479 479
 
480 480
 function getPrivateIconInfo($_style) {
481
-	if(!isset($_style['tree_page_gif_secure'])) {
482
-		$_style['tree_page_gif_secure'] = $_style['tree_page_secure'];
483
-	}
484
-	if(!isset($_style['tree_page_jpg_secure'])) {
485
-		$_style['tree_page_jpg_secure'] = $_style['tree_page_secure'];
486
-	}
487
-	if(!isset($_style['tree_page_png_secure'])) {
488
-		$_style['tree_page_png_secure'] = $_style['tree_page_secure'];
489
-	}
490
-	$iconsPrivate = array(
491
-		'text/html' => $_style['tree_page_html_secure'],
492
-		'text/plain' => $_style['tree_page_secure'],
493
-		'text/xml' => $_style['tree_page_xml_secure'],
494
-		'text/css' => $_style['tree_page_css_secure'],
495
-		'text/javascript' => $_style['tree_page_js_secure'],
496
-		'application/rss+xml' => $_style['tree_page_rss_secure'],
497
-		'application/pdf' => $_style['tree_page_pdf_secure'],
498
-		'application/vnd.ms-word' => $_style['tree_page_word_secure'],
499
-		'application/vnd.ms-excel' => $_style['tree_page_excel_secure'],
500
-		'image/gif' => $_style['tree_page_gif_secure'],
501
-		'image/jpg' => $_style['tree_page_jpg_secure'],
502
-		'image/png' => $_style['tree_page_png_secure']
503
-	);
504
-	return $iconsPrivate;
481
+    if(!isset($_style['tree_page_gif_secure'])) {
482
+        $_style['tree_page_gif_secure'] = $_style['tree_page_secure'];
483
+    }
484
+    if(!isset($_style['tree_page_jpg_secure'])) {
485
+        $_style['tree_page_jpg_secure'] = $_style['tree_page_secure'];
486
+    }
487
+    if(!isset($_style['tree_page_png_secure'])) {
488
+        $_style['tree_page_png_secure'] = $_style['tree_page_secure'];
489
+    }
490
+    $iconsPrivate = array(
491
+        'text/html' => $_style['tree_page_html_secure'],
492
+        'text/plain' => $_style['tree_page_secure'],
493
+        'text/xml' => $_style['tree_page_xml_secure'],
494
+        'text/css' => $_style['tree_page_css_secure'],
495
+        'text/javascript' => $_style['tree_page_js_secure'],
496
+        'application/rss+xml' => $_style['tree_page_rss_secure'],
497
+        'application/pdf' => $_style['tree_page_pdf_secure'],
498
+        'application/vnd.ms-word' => $_style['tree_page_word_secure'],
499
+        'application/vnd.ms-excel' => $_style['tree_page_excel_secure'],
500
+        'image/gif' => $_style['tree_page_gif_secure'],
501
+        'image/jpg' => $_style['tree_page_jpg_secure'],
502
+        'image/png' => $_style['tree_page_png_secure']
503
+    );
504
+    return $iconsPrivate;
505 505
 }
506 506
 
507 507
 function getNodeTitle($nodeNameSource, $row) {
508
-	global $modx;
509
-
510
-	switch($nodeNameSource) {
511
-		case 'menutitle':
512
-			$nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle'];
513
-			break;
514
-		case 'alias':
515
-			$nodetitle = $row['alias'] ? $row['alias'] : $row['id'];
516
-			if(strpos($row['alias'], '.') === false) {
517
-				if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) {
518
-					$nodetitle .= $modx->config['friendly_url_suffix'];
519
-				}
520
-			}
521
-			$nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
522
-			break;
523
-		case 'pagetitle':
524
-			$nodetitle = $row['pagetitle'];
525
-			break;
526
-		case 'longtitle':
527
-			$nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle'];
528
-			break;
529
-		case 'createdon':
530
-		case 'editedon':
531
-		case 'publishedon':
532
-		case 'pub_date':
533
-		case 'unpub_date':
534
-			$doc = $modx->getDocumentObject('id', $row['id']);
535
-			$date = $doc[$nodeNameSource];
536
-			if(!empty($date)) {
537
-				$nodetitle = $modx->toDateFormat($date);
538
-			} else {
539
-				$nodetitle = '- - -';
540
-			}
541
-			break;
542
-		default:
543
-			$nodetitle = $row['pagetitle'];
544
-	}
545
-	$nodetitle = $modx->htmlspecialchars(str_replace(array(
546
-		"\r\n",
547
-		"\n",
548
-		"\r"
549
-	), ' ', $nodetitle), ENT_COMPAT);
550
-	return $nodetitle;
508
+    global $modx;
509
+
510
+    switch($nodeNameSource) {
511
+        case 'menutitle':
512
+            $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle'];
513
+            break;
514
+        case 'alias':
515
+            $nodetitle = $row['alias'] ? $row['alias'] : $row['id'];
516
+            if(strpos($row['alias'], '.') === false) {
517
+                if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) {
518
+                    $nodetitle .= $modx->config['friendly_url_suffix'];
519
+                }
520
+            }
521
+            $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
522
+            break;
523
+        case 'pagetitle':
524
+            $nodetitle = $row['pagetitle'];
525
+            break;
526
+        case 'longtitle':
527
+            $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle'];
528
+            break;
529
+        case 'createdon':
530
+        case 'editedon':
531
+        case 'publishedon':
532
+        case 'pub_date':
533
+        case 'unpub_date':
534
+            $doc = $modx->getDocumentObject('id', $row['id']);
535
+            $date = $doc[$nodeNameSource];
536
+            if(!empty($date)) {
537
+                $nodetitle = $modx->toDateFormat($date);
538
+            } else {
539
+                $nodetitle = '- - -';
540
+            }
541
+            break;
542
+        default:
543
+            $nodetitle = $row['pagetitle'];
544
+    }
545
+    $nodetitle = $modx->htmlspecialchars(str_replace(array(
546
+        "\r\n",
547
+        "\n",
548
+        "\r"
549
+    ), ' ', $nodetitle), ENT_COMPAT);
550
+    return $nodetitle;
551 551
 }
552 552
 
553 553
 function isDateNode($nodeNameSource) {
554
-	switch($nodeNameSource) {
555
-		case 'createdon':
556
-		case 'editedon':
557
-		case 'publishedon':
558
-		case 'pub_date':
559
-		case 'unpub_date':
560
-			return true;
561
-		default:
562
-			return false;
563
-	}
554
+    switch($nodeNameSource) {
555
+        case 'createdon':
556
+        case 'editedon':
557
+        case 'publishedon':
558
+        case 'pub_date':
559
+        case 'unpub_date':
560
+            return true;
561
+        default:
562
+            return false;
563
+    }
564 564
 }
565 565
 
566 566
 function checkIsFolder($parent = 0, $isfolder = 1) {
567
-	global $modx;
567
+    global $modx;
568 568
 
569
-	return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' '));
569
+    return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' '));
570 570
 }
571 571
 
572 572
 function _htmlentities($array) {
573
-	global $modx;
573
+    global $modx;
574 574
 
575
-	$array = json_encode($array, JSON_UNESCAPED_UNICODE);
576
-	$array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']);
575
+    $array = json_encode($array, JSON_UNESCAPED_UNICODE);
576
+    $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']);
577 577
 
578
-	return $array;
578
+    return $array;
579 579
 }
580 580
 
581 581
 function getTplSingleNode() {
582
-	return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
582
+    return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
583 583
         onclick="modx.tree.treeAction(event,[+id+]);"
584 584
         oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');"
585 585
         data-id="[+id+]"
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 }
604 604
 
605 605
 function getTplFolderNode() {
606
-	return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
606
+    return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
607 607
         onclick="modx.tree.treeAction(event,[+id+]);"
608 608
         oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');"
609 609
         data-id="[+id+]"
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 }
640 640
 
641 641
 function getTplFolderNodeNotChildren() {
642
-	return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
642
+    return '<div id="node[+id+]"><a class="[+treeNodeClass+]"
643 643
         onclick="modx.tree.treeAction(event,[+id+]);"
644 644
         oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');"
645 645
         data-id="[+id+]"
@@ -671,10 +671,10 @@  discard block
 block discarded – undo
671 671
 }
672 672
 
673 673
 function dbug($str, $flag = false) {
674
-	print('<pre>');
675
-	print_r($str);
676
-	print('</pre>');
677
-	if($flag) {
678
-		exit;
679
-	}
674
+    print('<pre>');
675
+    print_r($str);
676
+    print('</pre>');
677
+    if($flag) {
678
+        exit;
679
+    }
680 680
 }
Please login to merge, or discard this patch.
manager/includes/categories.inc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -3,6 +3,9 @@
 block discarded – undo
3 3
 //Kyle Jaebker - 08/07/06
4 4
 
5 5
 //Create a new category
6
+/**
7
+ * @param string $newCat
8
+ */
6 9
 function newCategory($newCat) {
7 10
     global $modx;
8 11
     $useTable = $modx->getFullTableName('categories');
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
     $useTable = $modx->getFullTableName('categories');
20 20
     $newCat = $modx->db->escape($newCat);
21 21
     $cats = $modx->db->select('id', $modx->getFullTableName('categories'), "category='{$newCat}'");
22
-	if($cat = $modx->db->getValue($cats)) {
23
-		return $cat;
24
-	}
22
+    if($cat = $modx->db->getValue($cats)) {
23
+        return $cat;
24
+    }
25 25
     return 0;
26 26
 }
27 27
 //Check for category, create new if not exists
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     global $modx;
36 36
     $useTable = $modx->getFullTableName('categories');
37 37
     $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category');
38
-	$resourceArray = array();
38
+    $resourceArray = array();
39 39
     while($row = $modx->db->getRow($cats)) {
40 40
         $row['category'] = stripslashes($row['category']);
41 41
         $resourceArray[] = $row;
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@  discard block
 block discarded – undo
52 52
 	var $selPageClass;
53 53
 	var $noRecordMsg = "No records found.";
54 54
 
55
+	/**
56
+	 * @param string $id
57
+	 */
55 58
 	function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
56 59
 		global $__DataGridCnt;
57 60
 
@@ -187,6 +190,9 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// format column values
189 192
 
193
+	/**
194
+	 * @param integer $n
195
+	 */
190 196
 	function RenderRowFnc($n, $row) {
191 197
 		if($this->_alt == 0) {
192 198
 			$Style = $this->_itemStyle;
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -12,280 +12,280 @@
 block discarded – undo
12 12
 
13 13
 class DataGrid {
14 14
 
15
-	var $ds; // datasource
16
-	var $id;
17
-	var $pageSize;            // pager settings
18
-	var $pageNumber;
19
-	var $pager;
20
-	var $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21
-
22
-	var $cssStyle;
23
-	var $cssClass;
24
-
25
-	var $columnHeaderStyle;
26
-	var $columnHeaderClass;
27
-	var $itemStyle;
28
-	var $itemClass;
29
-	var $altItemStyle;
30
-	var $altItemClass;
31
-
32
-	var $fields;
33
-	var $columns;
34
-	var $colWidths;
35
-	var $colAligns;
36
-	var $colWraps;
37
-	var $colColors;
38
-	var $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
-	// data type: integer,float,currency,date
40
-
41
-	var $header;
42
-	var $footer;
43
-	var $cellPadding;
44
-	var $cellSpacing;
45
-
46
-	var $rowAlign;            // vertical alignment: top, middle, bottom
47
-	var $rowIdField;
48
-
49
-	var $pagerStyle;
50
-	var $pagerClass;
51
-	var $pageClass;
52
-	var $selPageClass;
53
-	var $noRecordMsg = "No records found.";
54
-
55
-	function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
56
-		global $__DataGridCnt;
57
-
58
-		// set id
59
-		$__DataGridCnt++;
60
-		$this->id = $this->id ? $id : "dg" . $__DataGridCnt;
61
-
62
-		// set datasource
63
-		$this->ds = $ds;
64
-
65
-		// set pager
66
-		$this->pageSize = $pageSize;
67
-		$this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number 
68
-		$this->pagerLocation = 'top-right';
69
-	}
70
-
71
-	function setDataSource($ds) {
72
-		$this->ds = $ds;
73
-	}
74
-
75
-	function render() {
76
-		global $modx;
77
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
78
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
79
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
80
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
81
-
82
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
83
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
84
-
85
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
86
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
87
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
88
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
89
-
90
-		$this->_alt = 0;
91
-		$this->_total = 0;
92
-
93
-		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
94
-
95
-		if(!$cssStyle && !$cssClass) {
96
-			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
97
-		}
98
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
99
-			$columnHeaderStyle = "style='color:black;background-color:silver'";
100
-		}
101
-		if(!$this->_itemStyle && !$this->_itemClass) {
102
-			$this->_itemStyle = "style='color:black;'";
103
-		}
104
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
105
-			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
106
-		}
107
-
108
-		if($this->_isDataset && !$this->columns) {
109
-			$cols = $modx->db->numFields($this->ds);
110
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
111
-		}
112
-
113
-		// start grid
114
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
115
-		$tblEnd = "</table>";
116
-
117
-		// build column header
118
-		$this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
119
-		$this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
120
-		$this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
121
-		$this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
122
-		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
123
-		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
124
-		$this->_colcount = count($this->_colnames);
125
-		if(!$this->_isDataset) {
126
-			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
127
-			$this->ds = array_chunk($this->ds, $this->_colcount);
128
-		}
129
-		$tblColHdr = "<thead><tr>";
130
-		for($c = 0; $c < $this->_colcount; $c++) {
131
-			$name = $this->_colnames[$c];
132
-			$width = $this->_colwidths[$c];
133
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
134
-		}
135
-		$tblColHdr .= "</tr></thead>\n";
136
-
137
-		// build rows
138
-		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
139
-		$this->_fieldnames = explode(",", $this->fields);
140
-		if($rowcount == 0) {
141
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
142
-		} else {
143
-			// render grid items
144
-			if($this->pageSize <= 0) {
145
-				for($r = 0; $r < $rowcount; $r++) {
146
-					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
147
-					$tblRows .= $this->RenderRowFnc($r + 1, $row);
148
-				}
149
-			} else {
150
-				if(!$this->pager) {
151
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
152
-					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
153
-					$this->pager->setRenderRowFnc($this); // pass this object
154
-					$this->pager->cssStyle = $pagerStyle;
155
-					$this->pager->cssClass = $pagerClass;
156
-				} else {
157
-					$this->pager->pageSize = $this->pageSize;
158
-					$this->pager->pageNumber = $this->pageNumber;
159
-				}
160
-
161
-				$this->pager->render();
162
-				$tblRows = $this->pager->getRenderedRows();
163
-				$tblPager = $this->pager->getRenderedPager();
164
-			}
165
-		}
166
-
167
-		// setup header,pager and footer
168
-		$o = $tblStart;
169
-		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
170
-		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
171
-		if($this->header) {
172
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
173
-		}
174
-		if($tblPager && $ptop) {
175
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
176
-		}
177
-		$o .= $tblColHdr . $tblRows;
178
-		if($tblPager && $pbot) {
179
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
180
-		}
181
-		if($this->footer) {
182
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
183
-		}
184
-		$o .= $tblEnd;
185
-		return $o;
186
-	}
187
-
188
-	// format column values
189
-
190
-	function RenderRowFnc($n, $row) {
191
-		if($this->_alt == 0) {
192
-			$Style = $this->_itemStyle;
193
-			$Class = $this->_itemClass;
194
-			$this->_alt = 1;
195
-		} else {
196
-			$Style = $this->_altItemStyle;
197
-			$Class = $this->_altItemClass;
198
-			$this->_alt = 0;
199
-		}
200
-		$o = "<tr>";
201
-		for($c = 0; $c < $this->_colcount; $c++) {
202
-			$colStyle = $Style;
203
-			$fld = trim($this->_fieldnames[$c]);
204
-			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
205
-			$align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
206
-			$color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
207
-			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
208
-			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
209
-			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
210
-			if($color && $Style) {
211
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
212
-			}
213
-			$value = $this->formatColumnValue($row, $value, $type, $align);
214
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
215
-		}
216
-		$o .= "</tr>\n";
217
-		return $o;
218
-	}
219
-
220
-	function formatColumnValue($row, $value, $type, &$align) {
221
-		if(strpos($type, ":") !== false) {
222
-			list($type, $type_format) = explode(":", $type, 2);
223
-		}
224
-		switch(strtolower($type)) {
225
-			case "integer":
226
-				if($align == "") {
227
-					$align = "right";
228
-				}
229
-				$value = number_format($value);
230
-				break;
231
-
232
-			case "float":
233
-				if($align == "") {
234
-					$align = "right";
235
-				}
236
-				if(!$type_format) {
237
-					$type_format = 2;
238
-				}
239
-				$value = number_format($value, $type_format);
240
-				break;
241
-
242
-			case "currency":
243
-				if($align == "") {
244
-					$align = "right";
245
-				}
246
-				if(!$type_format) {
247
-					$type_format = 2;
248
-				}
249
-				$value = "$" . number_format($value, $type_format);
250
-				break;
251
-
252
-			case "date":
253
-				if($align == "") {
254
-					$align = "right";
255
-				}
256
-				if(!is_numeric($value)) {
257
-					$value = strtotime($value);
258
-				}
259
-				if(!$type_format) {
260
-					$type_format = "%A %d, %B %Y";
261
-				}
262
-				$value = strftime($type_format, $value);
263
-				break;
264
-
265
-			case "boolean":
266
-				if($align == '') {
267
-					$align = "center";
268
-				}
269
-				$value = number_format($value);
270
-				if($value) {
271
-					$value = '&bull;';
272
-				} else {
273
-					$value = '&nbsp;';
274
-				}
275
-				break;
276
-
277
-			case "template":
278
-				// replace [+value+] first
279
-				$value = str_replace("[+value+]", $value, $type_format);
280
-				// replace other [+fields+]
281
-				if(strpos($value, "[+") !== false) {
282
-					foreach($row as $k => $v) {
283
-						$value = str_replace("[+$k+]", $v, $value);
284
-					}
285
-				}
286
-				break;
287
-
288
-		}
289
-		return $value;
290
-	}
15
+    var $ds; // datasource
16
+    var $id;
17
+    var $pageSize;            // pager settings
18
+    var $pageNumber;
19
+    var $pager;
20
+    var $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21
+
22
+    var $cssStyle;
23
+    var $cssClass;
24
+
25
+    var $columnHeaderStyle;
26
+    var $columnHeaderClass;
27
+    var $itemStyle;
28
+    var $itemClass;
29
+    var $altItemStyle;
30
+    var $altItemClass;
31
+
32
+    var $fields;
33
+    var $columns;
34
+    var $colWidths;
35
+    var $colAligns;
36
+    var $colWraps;
37
+    var $colColors;
38
+    var $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
+    // data type: integer,float,currency,date
40
+
41
+    var $header;
42
+    var $footer;
43
+    var $cellPadding;
44
+    var $cellSpacing;
45
+
46
+    var $rowAlign;            // vertical alignment: top, middle, bottom
47
+    var $rowIdField;
48
+
49
+    var $pagerStyle;
50
+    var $pagerClass;
51
+    var $pageClass;
52
+    var $selPageClass;
53
+    var $noRecordMsg = "No records found.";
54
+
55
+    function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
56
+        global $__DataGridCnt;
57
+
58
+        // set id
59
+        $__DataGridCnt++;
60
+        $this->id = $this->id ? $id : "dg" . $__DataGridCnt;
61
+
62
+        // set datasource
63
+        $this->ds = $ds;
64
+
65
+        // set pager
66
+        $this->pageSize = $pageSize;
67
+        $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number 
68
+        $this->pagerLocation = 'top-right';
69
+    }
70
+
71
+    function setDataSource($ds) {
72
+        $this->ds = $ds;
73
+    }
74
+
75
+    function render() {
76
+        global $modx;
77
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
78
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
79
+        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
80
+        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
81
+
82
+        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
83
+        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
84
+
85
+        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
86
+        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
87
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
88
+        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
89
+
90
+        $this->_alt = 0;
91
+        $this->_total = 0;
92
+
93
+        $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
94
+
95
+        if(!$cssStyle && !$cssClass) {
96
+            $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
97
+        }
98
+        if(!$columnHeaderStyle && !$columnHeaderClass) {
99
+            $columnHeaderStyle = "style='color:black;background-color:silver'";
100
+        }
101
+        if(!$this->_itemStyle && !$this->_itemClass) {
102
+            $this->_itemStyle = "style='color:black;'";
103
+        }
104
+        if(!$this->_altItemStyle && !$this->_altItemClass) {
105
+            $this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
106
+        }
107
+
108
+        if($this->_isDataset && !$this->columns) {
109
+            $cols = $modx->db->numFields($this->ds);
110
+            for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
111
+        }
112
+
113
+        // start grid
114
+        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
115
+        $tblEnd = "</table>";
116
+
117
+        // build column header
118
+        $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
119
+        $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
120
+        $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
121
+        $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
122
+        $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
123
+        $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
124
+        $this->_colcount = count($this->_colnames);
125
+        if(!$this->_isDataset) {
126
+            $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
127
+            $this->ds = array_chunk($this->ds, $this->_colcount);
128
+        }
129
+        $tblColHdr = "<thead><tr>";
130
+        for($c = 0; $c < $this->_colcount; $c++) {
131
+            $name = $this->_colnames[$c];
132
+            $width = $this->_colwidths[$c];
133
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
134
+        }
135
+        $tblColHdr .= "</tr></thead>\n";
136
+
137
+        // build rows
138
+        $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
139
+        $this->_fieldnames = explode(",", $this->fields);
140
+        if($rowcount == 0) {
141
+            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
142
+        } else {
143
+            // render grid items
144
+            if($this->pageSize <= 0) {
145
+                for($r = 0; $r < $rowcount; $r++) {
146
+                    $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
147
+                    $tblRows .= $this->RenderRowFnc($r + 1, $row);
148
+                }
149
+            } else {
150
+                if(!$this->pager) {
151
+                    include_once dirname(__FILE__) . "/datasetpager.class.php";
152
+                    $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
153
+                    $this->pager->setRenderRowFnc($this); // pass this object
154
+                    $this->pager->cssStyle = $pagerStyle;
155
+                    $this->pager->cssClass = $pagerClass;
156
+                } else {
157
+                    $this->pager->pageSize = $this->pageSize;
158
+                    $this->pager->pageNumber = $this->pageNumber;
159
+                }
160
+
161
+                $this->pager->render();
162
+                $tblRows = $this->pager->getRenderedRows();
163
+                $tblPager = $this->pager->getRenderedPager();
164
+            }
165
+        }
166
+
167
+        // setup header,pager and footer
168
+        $o = $tblStart;
169
+        $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
170
+        $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
171
+        if($this->header) {
172
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
173
+        }
174
+        if($tblPager && $ptop) {
175
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
176
+        }
177
+        $o .= $tblColHdr . $tblRows;
178
+        if($tblPager && $pbot) {
179
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
180
+        }
181
+        if($this->footer) {
182
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
183
+        }
184
+        $o .= $tblEnd;
185
+        return $o;
186
+    }
187
+
188
+    // format column values
189
+
190
+    function RenderRowFnc($n, $row) {
191
+        if($this->_alt == 0) {
192
+            $Style = $this->_itemStyle;
193
+            $Class = $this->_itemClass;
194
+            $this->_alt = 1;
195
+        } else {
196
+            $Style = $this->_altItemStyle;
197
+            $Class = $this->_altItemClass;
198
+            $this->_alt = 0;
199
+        }
200
+        $o = "<tr>";
201
+        for($c = 0; $c < $this->_colcount; $c++) {
202
+            $colStyle = $Style;
203
+            $fld = trim($this->_fieldnames[$c]);
204
+            $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
205
+            $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
206
+            $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
207
+            $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
208
+            $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
209
+            $value = $row[($this->_isDataset && $fld ? $fld : $c)];
210
+            if($color && $Style) {
211
+                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
212
+            }
213
+            $value = $this->formatColumnValue($row, $value, $type, $align);
214
+            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
215
+        }
216
+        $o .= "</tr>\n";
217
+        return $o;
218
+    }
219
+
220
+    function formatColumnValue($row, $value, $type, &$align) {
221
+        if(strpos($type, ":") !== false) {
222
+            list($type, $type_format) = explode(":", $type, 2);
223
+        }
224
+        switch(strtolower($type)) {
225
+            case "integer":
226
+                if($align == "") {
227
+                    $align = "right";
228
+                }
229
+                $value = number_format($value);
230
+                break;
231
+
232
+            case "float":
233
+                if($align == "") {
234
+                    $align = "right";
235
+                }
236
+                if(!$type_format) {
237
+                    $type_format = 2;
238
+                }
239
+                $value = number_format($value, $type_format);
240
+                break;
241
+
242
+            case "currency":
243
+                if($align == "") {
244
+                    $align = "right";
245
+                }
246
+                if(!$type_format) {
247
+                    $type_format = 2;
248
+                }
249
+                $value = "$" . number_format($value, $type_format);
250
+                break;
251
+
252
+            case "date":
253
+                if($align == "") {
254
+                    $align = "right";
255
+                }
256
+                if(!is_numeric($value)) {
257
+                    $value = strtotime($value);
258
+                }
259
+                if(!$type_format) {
260
+                    $type_format = "%A %d, %B %Y";
261
+                }
262
+                $value = strftime($type_format, $value);
263
+                break;
264
+
265
+            case "boolean":
266
+                if($align == '') {
267
+                    $align = "center";
268
+                }
269
+                $value = number_format($value);
270
+                if($value) {
271
+                    $value = '&bull;';
272
+                } else {
273
+                    $value = '&nbsp;';
274
+                }
275
+                break;
276
+
277
+            case "template":
278
+                // replace [+value+] first
279
+                $value = str_replace("[+value+]", $value, $type_format);
280
+                // replace other [+fields+]
281
+                if(strpos($value, "[+") !== false) {
282
+                    foreach($row as $k => $v) {
283
+                        $value = str_replace("[+$k+]", $v, $value);
284
+                    }
285
+                }
286
+                break;
287
+
288
+        }
289
+        return $value;
290
+    }
291 291
 }
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -73,6 +73,9 @@
 block discarded – undo
73 73
 		$this->pageSize = $ps;
74 74
 	}
75 75
 
76
+	/**
77
+	 * @param DataGrid $fncName
78
+	 */
76 79
 	function setRenderRowFnc($fncName, $args = "") {
77 80
 		$this->renderRowFnc = &$fncName;
78 81
 		$this->renderRowFncArgs = $args;    // extra agruments
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -12,181 +12,181 @@
 block discarded – undo
12 12
 
13 13
 class DataSetPager {
14 14
 
15
-	var $ds; // datasource
16
-	var $pageSize;
17
-	var $pageNumber;
18
-	var $rows;
19
-	var $pager;
20
-	var $id;
21
-
22
-	// normal page 
23
-	var $pageStyle;
24
-	var $pageClass;
25
-
26
-	// selected page
27
-	var $selPageStyle;
28
-	var $selPageClass;
29
-
30
-	function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
31
-		global $_PAGE; // use view state object
32
-
33
-		global $__DataSetPagerCnt;
34
-
35
-		// set id
36
-		$__DataSetPagerCnt++;
37
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
38
-
39
-		// get pagenumber
40
-		// by setting pager to -1 cause pager to load it's last page number
41
-		if($pageNumber == -1) {
42
-			$pageNumber = 1;
43
-			if(isset($_GET["dpgn" . $this->id])) {
44
-				$pageNumber = $_GET["dpgn" . $this->id];
45
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
46
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
47
-			}
48
-		}
49
-		if(!is_numeric($pageNumber)) {
50
-			$pageNumber = 1;
51
-		}
52
-
53
-		$this->ds = $ds; // datasource
54
-		$this->pageSize = $pageSize;
55
-		$this->pageNumber = $pageNumber;
56
-		$this->rows = '';
57
-		$this->pager = '';
58
-	}
59
-
60
-	function getRenderedPager() {
61
-		return $this->pager;
62
-	}
63
-
64
-	function getRenderedRows() {
65
-		return $this->rows;
66
-	}
67
-
68
-	function setDataSource($ds) {
69
-		$this->ds = $ds;
70
-	}
71
-
72
-	function setPageSize($ps) {
73
-		$this->pageSize = $ps;
74
-	}
75
-
76
-	function setRenderRowFnc($fncName, $args = "") {
77
-		$this->renderRowFnc = &$fncName;
78
-		$this->renderRowFncArgs = $args;    // extra agruments
79
-
80
-
81
-	}
82
-
83
-	function setRenderPagerFnc($fncName, $args = "") {
84
-		$this->renderPagerFnc = $fncName;
85
-		$this->renderPagerFncArgs = $args;    // extra agruments
86
-	}
87
-
88
-	function render() {
89
-		global $modx, $_PAGE;
90
-
91
-		$isDataset = $modx->db->isResult($this->ds);
92
-
93
-		if(!$this->selPageStyle) {
94
-			$this->selPageStyle = "font-weight:bold";
95
-		}
96
-
97
-		// get total number of rows		
98
-		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
99
-
100
-		// render: no records found
101
-		if($tnr <= 0) {
102
-			$fnc = $this->renderRowFnc;
103
-			$args = $this->renderRowFncArgs;
104
-			if(isset($fnc)) {
105
-				if($args != "") {
106
-					$this->rows .= $fnc(0, null, $args);
107
-				} // if agrs was specified then we will pass three params
108
-				else {
109
-					$this->rows .= $fnc(0, null);
110
-				}                 // otherwise two will be passed
111
-			}
112
-			return;
113
-		}
114
-
115
-		// get total pages
116
-		$tp = ceil($tnr / $this->pageSize);
117
-		if($this->pageNumber > $tp) {
118
-			$this->pageNumber = 1;
119
-		}
120
-
121
-		// get page number
122
-		$p = $this->pageNumber;
123
-
124
-		// save page number to view state if available
125
-		if(isset($_PAGE['vs'])) {
126
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
127
-		}
128
-
129
-		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
130
-		if($tp > 1) {
131
-			$fnc = $this->renderPagerFnc;
132
-			$args = $this->renderPagerFncArgs;
133
-			if(!isset($fnc)) {
134
-				if($modx->isFrontend()) {
135
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
136
-				} else {
137
-					$url = $_SERVER['PHP_SELF'] . '?';
138
-				}
139
-				$i = 0;
140
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
141
-					$i++;
142
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
143
-				}
144
-				if($i >= 1) {
145
-					$url .= "&";
146
-				}
147
-			}
148
-			for($i = 1; $i <= $tp; $i++) {
149
-				if(isset($fnc)) {
150
-					if($args != "") {
151
-						$this->pager .= $fnc($p, $i, $args);
152
-					} else {
153
-						$this->pager .= $fnc($p, $i);
154
-					}
155
-				} else {
156
-					$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> ";
157
-				}
158
-			}
159
-		}
160
-
161
-		// render row : renderRowFnc($rowNumber,$row,$arguments="")
162
-		$fnc = $this->renderRowFnc;
163
-		$args = $this->renderRowFncArgs;
164
-
165
-		if(isset($fnc)) {
166
-			$i = 1;
167
-			$fncObject = is_object($fnc);
168
-			$minitems = (($p - 1) * $this->pageSize) + 1;
169
-			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
170
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
171
-				if($i >= $minitems && $i <= $maxitems) {
172
-					if($fncObject) {
173
-						if($args != "") {
174
-							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
175
-						} else {
176
-							$this->rows .= $fnc->RenderRowFnc($i, $row);
177
-						}
178
-					} else {
179
-						if($args != "") {
180
-							$this->rows .= $fnc($i, $row, $args);
181
-						} // if agrs was specified then we wil pass three params
182
-						else {
183
-							$this->rows .= $fnc($i, $row);
184
-						}                 // otherwise two will be passed
185
-					}
186
-
187
-				}
188
-				$i++;
189
-			}
190
-		}
191
-	}
15
+    var $ds; // datasource
16
+    var $pageSize;
17
+    var $pageNumber;
18
+    var $rows;
19
+    var $pager;
20
+    var $id;
21
+
22
+    // normal page 
23
+    var $pageStyle;
24
+    var $pageClass;
25
+
26
+    // selected page
27
+    var $selPageStyle;
28
+    var $selPageClass;
29
+
30
+    function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
31
+        global $_PAGE; // use view state object
32
+
33
+        global $__DataSetPagerCnt;
34
+
35
+        // set id
36
+        $__DataSetPagerCnt++;
37
+        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
38
+
39
+        // get pagenumber
40
+        // by setting pager to -1 cause pager to load it's last page number
41
+        if($pageNumber == -1) {
42
+            $pageNumber = 1;
43
+            if(isset($_GET["dpgn" . $this->id])) {
44
+                $pageNumber = $_GET["dpgn" . $this->id];
45
+            } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
46
+                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
47
+            }
48
+        }
49
+        if(!is_numeric($pageNumber)) {
50
+            $pageNumber = 1;
51
+        }
52
+
53
+        $this->ds = $ds; // datasource
54
+        $this->pageSize = $pageSize;
55
+        $this->pageNumber = $pageNumber;
56
+        $this->rows = '';
57
+        $this->pager = '';
58
+    }
59
+
60
+    function getRenderedPager() {
61
+        return $this->pager;
62
+    }
63
+
64
+    function getRenderedRows() {
65
+        return $this->rows;
66
+    }
67
+
68
+    function setDataSource($ds) {
69
+        $this->ds = $ds;
70
+    }
71
+
72
+    function setPageSize($ps) {
73
+        $this->pageSize = $ps;
74
+    }
75
+
76
+    function setRenderRowFnc($fncName, $args = "") {
77
+        $this->renderRowFnc = &$fncName;
78
+        $this->renderRowFncArgs = $args;    // extra agruments
79
+
80
+
81
+    }
82
+
83
+    function setRenderPagerFnc($fncName, $args = "") {
84
+        $this->renderPagerFnc = $fncName;
85
+        $this->renderPagerFncArgs = $args;    // extra agruments
86
+    }
87
+
88
+    function render() {
89
+        global $modx, $_PAGE;
90
+
91
+        $isDataset = $modx->db->isResult($this->ds);
92
+
93
+        if(!$this->selPageStyle) {
94
+            $this->selPageStyle = "font-weight:bold";
95
+        }
96
+
97
+        // get total number of rows		
98
+        $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
99
+
100
+        // render: no records found
101
+        if($tnr <= 0) {
102
+            $fnc = $this->renderRowFnc;
103
+            $args = $this->renderRowFncArgs;
104
+            if(isset($fnc)) {
105
+                if($args != "") {
106
+                    $this->rows .= $fnc(0, null, $args);
107
+                } // if agrs was specified then we will pass three params
108
+                else {
109
+                    $this->rows .= $fnc(0, null);
110
+                }                 // otherwise two will be passed
111
+            }
112
+            return;
113
+        }
114
+
115
+        // get total pages
116
+        $tp = ceil($tnr / $this->pageSize);
117
+        if($this->pageNumber > $tp) {
118
+            $this->pageNumber = 1;
119
+        }
120
+
121
+        // get page number
122
+        $p = $this->pageNumber;
123
+
124
+        // save page number to view state if available
125
+        if(isset($_PAGE['vs'])) {
126
+            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
127
+        }
128
+
129
+        // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
130
+        if($tp > 1) {
131
+            $fnc = $this->renderPagerFnc;
132
+            $args = $this->renderPagerFncArgs;
133
+            if(!isset($fnc)) {
134
+                if($modx->isFrontend()) {
135
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
136
+                } else {
137
+                    $url = $_SERVER['PHP_SELF'] . '?';
138
+                }
139
+                $i = 0;
140
+                foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
141
+                    $i++;
142
+                    $url .= (($i > 1) ? "&" : "") . "$n=$v";
143
+                }
144
+                if($i >= 1) {
145
+                    $url .= "&";
146
+                }
147
+            }
148
+            for($i = 1; $i <= $tp; $i++) {
149
+                if(isset($fnc)) {
150
+                    if($args != "") {
151
+                        $this->pager .= $fnc($p, $i, $args);
152
+                    } else {
153
+                        $this->pager .= $fnc($p, $i);
154
+                    }
155
+                } else {
156
+                    $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> ";
157
+                }
158
+            }
159
+        }
160
+
161
+        // render row : renderRowFnc($rowNumber,$row,$arguments="")
162
+        $fnc = $this->renderRowFnc;
163
+        $args = $this->renderRowFncArgs;
164
+
165
+        if(isset($fnc)) {
166
+            $i = 1;
167
+            $fncObject = is_object($fnc);
168
+            $minitems = (($p - 1) * $this->pageSize) + 1;
169
+            $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
170
+            while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
171
+                if($i >= $minitems && $i <= $maxitems) {
172
+                    if($fncObject) {
173
+                        if($args != "") {
174
+                            $this->rows .= $fnc->RenderRowFnc($i, $row, $args);
175
+                        } else {
176
+                            $this->rows .= $fnc->RenderRowFnc($i, $row);
177
+                        }
178
+                    } else {
179
+                        if($args != "") {
180
+                            $this->rows .= $fnc($i, $row, $args);
181
+                        } // if agrs was specified then we wil pass three params
182
+                        else {
183
+                            $this->rows .= $fnc($i, $row);
184
+                        }                 // otherwise two will be passed
185
+                    }
186
+
187
+                }
188
+                $i++;
189
+            }
190
+        }
191
+    }
192 192
 }
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/PHPMailer.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3968,7 +3968,7 @@
 block discarded – undo
3968 3968
      * @param int|string $options Either a PATHINFO_* constant,
3969 3969
      *                            or a string name to return only the specified piece
3970 3970
      *
3971
-     * @return string|array
3971
+     * @return string
3972 3972
      */
3973 3973
     public static function mb_pathinfo($path, $options = null)
3974 3974
     {
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/POP3.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
      * Connect to a POP3 server.
210 210
      *
211 211
      * @param string   $host
212
-     * @param int|bool $port
212
+     * @param integer $port
213 213
      * @param int      $tval
214 214
      *
215 215
      * @return bool
Please login to merge, or discard this patch.
manager/includes/controls/phpmailer/SMTP.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1314,7 +1314,7 @@
 block discarded – undo
1314 1314
      * If no reply has been received yet, it will return null.
1315 1315
      * If no pattern was matched, it will return false.
1316 1316
      *
1317
-     * @return bool|null|string
1317
+     * @return string
1318 1318
      *
1319 1319
      * @see recordLastTransactionID()
1320 1320
      */
Please login to merge, or discard this patch.