@@ -565,6 +565,9 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -801,7 +801,7 @@ |
||
801 | 801 | $complete_name = $path . str_replace('\\', '/', $zip_entry_name); |
802 | 802 | if (!file_exists($complete_path)) { |
803 | 803 | $tmp = ''; |
804 | - foreach (explode('/', $complete_path) AS $k) { |
|
804 | + foreach (explode('/', $complete_path) as $k) { |
|
805 | 805 | $tmp .= $k . '/'; |
806 | 806 | if (!is_dir($tmp)) { |
807 | 807 | mkdir($tmp, 0777); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | if (!$modx->hasPermission('file_manager')) { |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | $newToken = makeToken(); |
10 | 10 | |
11 | 11 | // settings |
12 | -$theme_image_path = $modx->config['site_manager_url'] . 'media/style/' . $modx->config['manager_theme'] . '/images/'; |
|
12 | +$theme_image_path = $modx->config['site_manager_url'].'media/style/'.$modx->config['manager_theme'].'/images/'; |
|
13 | 13 | $excludes = array( |
14 | 14 | '.', |
15 | 15 | '..', |
16 | 16 | '.svn' |
17 | 17 | ); |
18 | -$alias_suffix = (!empty($friendly_url_suffix)) ? ',' . ltrim($friendly_url_suffix, '.') : ''; |
|
19 | -$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
20 | -$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json' . $alias_suffix); |
|
18 | +$alias_suffix = (!empty($friendly_url_suffix)) ? ','.ltrim($friendly_url_suffix, '.') : ''; |
|
19 | +$editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
20 | +$inlineviewablefiles = explode(',', 'txt,php,tpl,less,sass,html,htm,xml,js,css,pageCache,htaccess,json'.$alias_suffix); |
|
21 | 21 | $viewablefiles = explode(',', 'jpg,gif,png,ico'); |
22 | 22 | |
23 | 23 | $editablefiles = add_dot($editablefiles); |
@@ -30,31 +30,31 @@ discard block |
||
30 | 30 | { |
31 | 31 | */ |
32 | 32 | $protected_path[] = $modx->config['site_manager_path']; |
33 | -$protected_path[] = $modx->config['base_path'] . 'temp/backup'; |
|
34 | -$protected_path[] = $modx->config['base_path'] . 'assets/backup'; |
|
33 | +$protected_path[] = $modx->config['base_path'].'temp/backup'; |
|
34 | +$protected_path[] = $modx->config['base_path'].'assets/backup'; |
|
35 | 35 | |
36 | 36 | if (!$modx->hasPermission('save_plugin')) { |
37 | - $protected_path[] = $modx->config['base_path'] . 'assets/plugins'; |
|
37 | + $protected_path[] = $modx->config['base_path'].'assets/plugins'; |
|
38 | 38 | } |
39 | 39 | if (!$modx->hasPermission('save_snippet')) { |
40 | - $protected_path[] = $modx->config['base_path'] . 'assets/snippets'; |
|
40 | + $protected_path[] = $modx->config['base_path'].'assets/snippets'; |
|
41 | 41 | } |
42 | 42 | if (!$modx->hasPermission('save_template')) { |
43 | - $protected_path[] = $modx->config['base_path'] . 'assets/templates'; |
|
43 | + $protected_path[] = $modx->config['base_path'].'assets/templates'; |
|
44 | 44 | } |
45 | 45 | if (!$modx->hasPermission('save_module')) { |
46 | - $protected_path[] = $modx->config['base_path'] . 'assets/modules'; |
|
46 | + $protected_path[] = $modx->config['base_path'].'assets/modules'; |
|
47 | 47 | } |
48 | 48 | if (!$modx->hasPermission('empty_cache')) { |
49 | - $protected_path[] = $modx->config['base_path'] . 'assets/cache'; |
|
49 | + $protected_path[] = $modx->config['base_path'].'assets/cache'; |
|
50 | 50 | } |
51 | 51 | if (!$modx->hasPermission('import_static')) { |
52 | - $protected_path[] = $modx->config['base_path'] . 'temp/import'; |
|
53 | - $protected_path[] = $modx->config['base_path'] . 'assets/import'; |
|
52 | + $protected_path[] = $modx->config['base_path'].'temp/import'; |
|
53 | + $protected_path[] = $modx->config['base_path'].'assets/import'; |
|
54 | 54 | } |
55 | 55 | if (!$modx->hasPermission('export_static')) { |
56 | - $protected_path[] = $modx->config['base_path'] . 'temp/export'; |
|
57 | - $protected_path[] = $modx->config['base_path'] . 'assets/export'; |
|
56 | + $protected_path[] = $modx->config['base_path'].'temp/export'; |
|
57 | + $protected_path[] = $modx->config['base_path'].'assets/export'; |
|
58 | 58 | } |
59 | 59 | /* |
60 | 60 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | $count = count($array); |
81 | 81 | for ($i = 0; $i < $count; $i++) { |
82 | - $array[$i] = '.' . strtolower(trim($array[$i])); // add a dot :) |
|
82 | + $array[$i] = '.'.strtolower(trim($array[$i])); // add a dot :) |
|
83 | 83 | } |
84 | 84 | return $array; |
85 | 85 | } |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | $rw = realpath('../'); |
105 | 105 | $webstart_path = str_replace('\\', '/', str_replace($rw, '', $rf)); |
106 | 106 | if (substr($webstart_path, 0, 1) == '/') { |
107 | - $webstart_path = '..' . $webstart_path; |
|
107 | + $webstart_path = '..'.$webstart_path; |
|
108 | 108 | } else { |
109 | - $webstart_path = '../' . $webstart_path; |
|
109 | + $webstart_path = '../'.$webstart_path; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | ?> |
113 | 113 | <script type="text/javascript"> |
114 | 114 | |
115 | - var current_path = '<?= $startpath;?>'; |
|
115 | + var current_path = '<?= $startpath; ?>'; |
|
116 | 116 | |
117 | 117 | function viewfile (url) |
118 | 118 | { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | function unzipFile (file) |
149 | 149 | { |
150 | 150 | if (confirmUnzip()) { |
151 | - window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken;?>"; |
|
151 | + window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken; ?>"; |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | function deleteFolder (folder, status) |
171 | 171 | { |
172 | 172 | if (confirmDeleteFolder(status)) { |
173 | - window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken;?>"; |
|
173 | + window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken; ?>"; |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | function deleteFile (file) |
179 | 179 | { |
180 | 180 | if (confirmDelete()) { |
181 | - window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken;?>"; |
|
181 | + window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken; ?>"; |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
189 | 189 | if (newFilename !== null && newFilename !== file) { |
190 | - window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
190 | + window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | { |
196 | 196 | var newDirname = prompt("<?= $_lang["files_dynamic_new_folder_name"] ?>", dir); |
197 | 197 | if (newDirname !== null && newDirname !== dir) { |
198 | - window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken;?>"; |
|
198 | + window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken; ?>"; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file); |
205 | 205 | if (newFilename !== null && newFilename !== file) { |
206 | - window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>"; |
|
206 | + window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken; ?>"; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | <?php endif ?> |
223 | 223 | <?php |
224 | 224 | if (isset($_GET['mode']) && $_GET['mode'] !== 'drill') { |
225 | - $href = 'a=31&path=' . urlencode($_REQUEST['path']); |
|
225 | + $href = 'a=31&path='.urlencode($_REQUEST['path']); |
|
226 | 226 | } else { |
227 | 227 | $href = 'a=2'; |
228 | 228 | } |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFolderName(this);"><i class="[+image+]"></i><span>[+subject+]</span></a>'; |
233 | 233 | $ph['image'] = $_style['files_folder-open']; |
234 | 234 | $ph['subject'] = $_lang['add_folder']; |
235 | - $ph['href'] = 'index.php?a=31&mode=newfolder&path=' . urlencode($startpath) . '&name='; |
|
235 | + $ph['href'] = 'index.php?a=31&mode=newfolder&path='.urlencode($startpath).'&name='; |
|
236 | 236 | $_ = parsePlaceholder($tpl, $ph); |
237 | 237 | |
238 | - $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>' . $_lang['files.dynamic.php1'] . '</span></a>'; |
|
238 | + $tpl = '<a class="btn btn-secondary" href="[+href+]" onclick="return getFileName(this);"><i class="[+image+]"></i><span>'.$_lang['files.dynamic.php1'].'</span></a>'; |
|
239 | 239 | $ph['image'] = $_style['files_page_html']; |
240 | - $ph['href'] = 'index.php?a=31&mode=newfile&path=' . urlencode($startpath) . '&name='; |
|
240 | + $ph['href'] = 'index.php?a=31&mode=newfile&path='.urlencode($startpath).'&name='; |
|
241 | 241 | $_ .= parsePlaceholder($tpl, $ph); |
242 | 242 | echo $_; |
243 | 243 | } |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | $ph = array(); |
268 | 268 | $ph['style_path'] = $theme_image_path; |
269 | 269 | // To Top Level with folder icon to the left |
270 | - if ($startpath == $filemanager_path || $startpath . '/' == $filemanager_path) { |
|
271 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
270 | + if ($startpath == $filemanager_path || $startpath.'/' == $filemanager_path) { |
|
271 | + $ph['image'] = ''.$_style['files_top'].''; |
|
272 | 272 | $ph['subject'] = '<span>Top</span>'; |
273 | 273 | } else { |
274 | - $ph['image'] = '' . $_style['files_top'] . ''; |
|
275 | - $ph['subject'] = '<a href="index.php?a=31&mode=drill&path=' . $filemanager_path . '">Top</a>/'; |
|
274 | + $ph['image'] = ''.$_style['files_top'].''; |
|
275 | + $ph['subject'] = '<a href="index.php?a=31&mode=drill&path='.$filemanager_path.'">Top</a>/'; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | echo parsePlaceholder($tpl, $ph); |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | if (empty($v)) { |
290 | 290 | continue; |
291 | 291 | } |
292 | - $path .= rtrim($v, '/') . '/'; |
|
292 | + $path .= rtrim($v, '/').'/'; |
|
293 | 293 | if (1 < $count) { |
294 | - $href = 'index.php?a=31&mode=drill&path=' . urlencode($filemanager_path . $path); |
|
295 | - $pieces[$i] = '<a href="' . $href . '">' . trim($v, '/') . '</a>'; |
|
294 | + $href = 'index.php?a=31&mode=drill&path='.urlencode($filemanager_path.$path); |
|
295 | + $pieces[$i] = '<a href="'.$href.'">'.trim($v, '/').'</a>'; |
|
296 | 296 | } else { |
297 | - $pieces[$i] = '<span>' . trim($v, '/') . '</span>'; |
|
297 | + $pieces[$i] = '<span>'.trim($v, '/').'</span>'; |
|
298 | 298 | } |
299 | 299 | $count--; |
300 | 300 | } |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | </div> |
308 | 308 | <?php |
309 | 309 | // check to see user isn't trying to move below the document_root |
310 | - if (substr(strtolower(str_replace('//', '/', $startpath . "/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path . '/'))) { |
|
310 | + if (substr(strtolower(str_replace('//', '/', $startpath."/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path.'/'))) { |
|
311 | 311 | $modx->webAlertAndQuit($_lang["files_access_denied"]); |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Unzip .zip files - by Raymond |
315 | 315 | if ($enablefileunzip && $_REQUEST['mode'] == 'unzip' && is_writable($startpath)) { |
316 | - if (!$err = unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath))) { |
|
317 | - echo '<span class="warning"><b>' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '</b></span><br /><br />'; |
|
316 | + if (!$err = unzip(realpath("{$startpath}/".$_REQUEST['file']), realpath($startpath))) { |
|
317 | + echo '<span class="warning"><b>'.$_lang['file_unzip_fail'].($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '').'</b></span><br /><br />'; |
|
318 | 318 | } else { |
319 | - echo '<span class="success"><b>' . $_lang['file_unzip'] . '</b></span><br /><br />'; |
|
319 | + echo '<span class="success"><b>'.$_lang['file_unzip'].'</b></span><br /><br />'; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | // End Unzip - Raymond |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | if ($_REQUEST['mode'] == 'deletefolder') { |
329 | 329 | $folder = $_REQUEST['folderpath']; |
330 | 330 | if (!$token_check || !@rrmdir($folder)) { |
331 | - echo '<span class="warning"><b>' . $_lang['file_folder_not_deleted'] . '</b></span><br /><br />'; |
|
331 | + echo '<span class="warning"><b>'.$_lang['file_folder_not_deleted'].'</b></span><br /><br />'; |
|
332 | 332 | } else { |
333 | - echo '<span class="success"><b>' . $_lang['file_folder_deleted'] . '</b></span><br /><br />'; |
|
333 | + echo '<span class="success"><b>'.$_lang['file_folder_deleted'].'</b></span><br /><br />'; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | if (!mkdirs("{$startpath}/{$foldername}", 0777)) { |
342 | 342 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
343 | 343 | } else { |
344 | - if (!@chmod($startpath . '/' . $foldername, $newfolderaccessmode)) { |
|
345 | - echo '<span class="warning"><b>' . $_lang['file_folder_chmod_error'] . '</b></span><br /><br />'; |
|
344 | + if (!@chmod($startpath.'/'.$foldername, $newfolderaccessmode)) { |
|
345 | + echo '<span class="warning"><b>'.$_lang['file_folder_chmod_error'].'</b></span><br /><br />'; |
|
346 | 346 | } else { |
347 | - echo '<span class="success"><b>' . $_lang['file_folder_created'] . '</b></span><br /><br />'; |
|
347 | + echo '<span class="success"><b>'.$_lang['file_folder_created'].'</b></span><br /><br />'; |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | umask($old_umask); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $filename = $modx->db->escape($filename); |
357 | 357 | |
358 | 358 | if (!checkExtension($filename)) { |
359 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
359 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
360 | 360 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $filename) !== 0) { |
361 | 361 | echo $_lang['files.dynamic.php3']; |
362 | 362 | } else { |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | $newFilename = $modx->db->escape($newFilename); |
379 | 379 | |
380 | 380 | if (!checkExtension($newFilename)) { |
381 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
381 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
382 | 382 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
383 | 383 | echo $_lang['files.dynamic.php3']; |
384 | 384 | } else { |
385 | - if (!copy($filename, MODX_BASE_PATH . $newFilename)) { |
|
385 | + if (!copy($filename, MODX_BASE_PATH.$newFilename)) { |
|
386 | 386 | echo $_lang['files.dynamic.php5']; |
387 | 387 | } |
388 | 388 | umask($old_umask); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | // Rename folder here |
392 | 392 | if ($_REQUEST['mode'] == 'renameFolder') { |
393 | 393 | $old_umask = umask(0); |
394 | - $dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname']; |
|
394 | + $dirname = $_REQUEST['path'].'/'.$_REQUEST['dirname']; |
|
395 | 395 | $dirname = $modx->db->escape($dirname); |
396 | 396 | $newDirname = str_replace(array( |
397 | 397 | '..\\', |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | if (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) { |
405 | 405 | echo $_lang['files.dynamic.php3']; |
406 | - } else if (!rename($dirname, $_REQUEST['path'] . '/' . $newDirname)) { |
|
406 | + } else if (!rename($dirname, $_REQUEST['path'].'/'.$newDirname)) { |
|
407 | 407 | echo '<span class="warning"><b>', $_lang['file_folder_not_created'], '</b></span><br /><br />'; |
408 | 408 | } |
409 | 409 | umask($old_umask); |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | $newFilename = $modx->db->escape($newFilename); |
424 | 424 | |
425 | 425 | if (!checkExtension($newFilename)) { |
426 | - echo '<span class="warning"><b>' . $_lang['files_filetype_notok'] . '</b></span><br /><br />'; |
|
426 | + echo '<span class="warning"><b>'.$_lang['files_filetype_notok'].'</b></span><br /><br />'; |
|
427 | 427 | } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { |
428 | 428 | echo $_lang['files.dynamic.php3']; |
429 | 429 | } else { |
430 | - if (!rename($filename, $path . '/' . $newFilename)) { |
|
430 | + if (!rename($filename, $path.'/'.$newFilename)) { |
|
431 | 431 | echo $_lang['files.dynamic.php5']; |
432 | 432 | } |
433 | 433 | umask($old_umask); |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | ls($startpath); |
461 | 461 | echo "\n\n\n"; |
462 | 462 | if ($folders == 0 && $files == 0) { |
463 | - echo '<tr><td colspan="4"><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> ' . $_lang['files_directory_is_empty'] . ' </span></td></tr>'; |
|
463 | + echo '<tr><td colspan="4"><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> <span style="color:#888;cursor:default;"> '.$_lang['files_directory_is_empty'].' </span></td></tr>'; |
|
464 | 464 | } |
465 | 465 | ?> |
466 | 466 | </table> |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | <div class="container"> |
470 | 470 | <p> |
471 | 471 | <?php |
472 | - echo $_lang['files_directories'] . ': <b>' . $folders . '</b> '; |
|
473 | - echo $_lang['files_files'] . ': <b>' . $files . '</b> '; |
|
474 | - echo $_lang['files_data'] . ': <b><span dir="ltr">' . $modx->nicesize($filesizes) . '</span></b> '; |
|
475 | - echo $_lang['files_dirwritable'] . ' <b>' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.</b>' |
|
472 | + echo $_lang['files_directories'].': <b>'.$folders.'</b> '; |
|
473 | + echo $_lang['files_files'].': <b>'.$files.'</b> '; |
|
474 | + echo $_lang['files_data'].': <b><span dir="ltr">'.$modx->nicesize($filesizes).'</span></b> '; |
|
475 | + echo $_lang['files_dirwritable'].' <b>'.(is_writable($startpath) == 1 ? $_lang['yes'].'.' : $_lang['no']).'.</b>' |
|
476 | 476 | ?> |
477 | 477 | </p> |
478 | 478 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | </form> |
498 | 498 | <?php |
499 | 499 | } else { |
500 | - echo "<p>" . $_lang['files_upload_inhibited_msg'] . "</p>"; |
|
500 | + echo "<p>".$_lang['files_upload_inhibited_msg']."</p>"; |
|
501 | 501 | } |
502 | 502 | ?> |
503 | 503 | <div id="imageviewer"></div> |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | if ($file == $selFile) { |
577 | 577 | $icon = isset($icons[$mode]) ? $icons[$mode] : $icons['default']; |
578 | 578 | } |
579 | - return '<i class="' . $icon . ' FilesPage"></i>'; |
|
579 | + return '<i class="'.$icon.' FilesPage"></i>'; |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | function markRow($file, $selFile, $mode) |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | ); |
589 | 589 | if ($file == $selFile) { |
590 | 590 | $class = isset($classNames[$mode]) ? $classNames[$mode] : $classNames['default']; |
591 | - return ' class="' . $class . '"'; |
|
591 | + return ' class="'.$class.'"'; |
|
592 | 592 | } |
593 | 593 | return ''; |
594 | 594 | } |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | global $excludes, $protected_path, $editablefiles, $inlineviewablefiles, $viewablefiles, $enablefileunzip, $enablefiledownload, $uploadablefiles, $folders, $files, $filesizes, $len, $dirs_array, $files_array, $webstart_path, $modx; |
600 | 600 | $dircounter = 0; |
601 | 601 | $filecounter = 0; |
602 | - $curpath = str_replace('//', '/', $curpath . '/'); |
|
602 | + $curpath = str_replace('//', '/', $curpath.'/'); |
|
603 | 603 | |
604 | 604 | if (!is_dir($curpath)) { |
605 | 605 | echo 'Invalid path "', $curpath, '"<br />'; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | // first, get info |
611 | 611 | foreach ($dir as $file) { |
612 | - $newpath = $curpath . $file; |
|
612 | + $newpath = $curpath.$file; |
|
613 | 613 | if ($file === '..' || $file === '.') { |
614 | 614 | continue; |
615 | 615 | } |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | if ($file === '..' || $file === '.') { |
620 | 620 | continue; |
621 | 621 | } elseif (!in_array($file, $excludes) && !in_array($newpath, $protected_path)) { |
622 | - $dirs_array[$dircounter]['text'] = '<i class="' . $_style['files_folder'] . ' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path=' . urlencode($newpath) . '"><b>' . $file . '</b></a>'; |
|
622 | + $dirs_array[$dircounter]['text'] = '<i class="'.$_style['files_folder'].' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path='.urlencode($newpath).'"><b>'.$file.'</b></a>'; |
|
623 | 623 | |
624 | 624 | $dfiles = scandir($newpath); |
625 | 625 | foreach ($dfiles as $i => $infile) { |
@@ -632,13 +632,13 @@ discard block |
||
632 | 632 | } |
633 | 633 | $file_exists = (0 < count($dfiles)) ? 'file_exists' : ''; |
634 | 634 | |
635 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\'' . urlencode($file) . '\',\'' . $file_exists . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></a>' : ''; |
|
635 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<a href="javascript: deleteFolder(\''.urlencode($file).'\',\''.$file_exists.'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></a>' : ''; |
|
636 | 636 | } else { |
637 | - $dirs_array[$dircounter]['text'] = '<span><i class="' . $_style['files_deleted_folder'] . ' FilesDeletedFolder"></i> ' . $file . '</span>'; |
|
638 | - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_folder'] . '"></i></span>' : ''; |
|
637 | + $dirs_array[$dircounter]['text'] = '<span><i class="'.$_style['files_deleted_folder'].' FilesDeletedFolder"></i> '.$file.'</span>'; |
|
638 | + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_folder'].'"></i></span>' : ''; |
|
639 | 639 | } |
640 | 640 | |
641 | - $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" title="' . $_lang['rename'] . '"></i></a> ' : ''; |
|
641 | + $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? '<a href="javascript:renameFolder(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" title="'.$_lang['rename'].'"></i></a> ' : ''; |
|
642 | 642 | |
643 | 643 | // increment the counter |
644 | 644 | $dircounter++; |
@@ -646,14 +646,14 @@ discard block |
||
646 | 646 | $type = getExtension($newpath); |
647 | 647 | $files_array[$filecounter]['file'] = $newpath; |
648 | 648 | $files_array[$filecounter]['stats'] = lstat($newpath); |
649 | - $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']) . ' ' . $file; |
|
650 | - $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\'' . $webstart_path . substr($newpath, $len, strlen($newpath)) . '\');"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="' . $webstart_path . implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))) . '" style="cursor:pointer;"><i class="' . $_style['files_download'] . '" title="' . $_lang['file_download_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></span>'); |
|
651 | - $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path=' . urlencode($newpath) . '"><i class="' . $_style['files_view'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : $files_array[$filecounter]['view']; |
|
652 | - $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_unzip'] . '" title="' . $_lang['file_download_unzip'] . '"></i></a>' : ''; |
|
653 | - $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path=' . urlencode($newpath) . '#file_editfile"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></span>'; |
|
654 | - $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_duplicate'] . '" title="' . $_lang['duplicate'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_duplicate'] . '" align="absmiddle" title="' . $_lang['duplicate'] . '"></i></span>'; |
|
655 | - $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_rename'] . '" align="absmiddle" title="' . $_lang['rename'] . '"></i></span>'; |
|
656 | - $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\'' . urlencode($file) . '\');"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['files_delete'] . '" title="' . $_lang['file_delete_file'] . '"></i></span>'; |
|
649 | + $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']).' '.$file; |
|
650 | + $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '<a href="javascript:;" onclick="viewfile(\''.$webstart_path.substr($newpath, $len, strlen($newpath)).'\');"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '<a href="'.$webstart_path.implode('/', array_map('rawurlencode', explode('/', substr($newpath, $len, strlen($newpath))))).'" style="cursor:pointer;"><i class="'.$_style['files_download'].'" title="'.$_lang['file_download_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></span>'); |
|
651 | + $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path='.urlencode($newpath).'"><i class="'.$_style['files_view'].'" title="'.$_lang['files_viewfile'].'"></i></a>' : $files_array[$filecounter]['view']; |
|
652 | + $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\''.urlencode($file).'\');"><i class="'.$_style['files_unzip'].'" title="'.$_lang['file_download_unzip'].'"></i></a>' : ''; |
|
653 | + $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path='.urlencode($newpath).'#file_editfile"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_edit'].'" title="'.$_lang['files_editfile'].'"></i></span>'; |
|
654 | + $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\''.urlencode($file).'\');"><i class="'.$_style['files_duplicate'].'" title="'.$_lang['duplicate'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_duplicate'].'" align="absmiddle" title="'.$_lang['duplicate'].'"></i></span>'; |
|
655 | + $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:renameFile(\''.urlencode($file).'\');"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_rename'].'" align="absmiddle" title="'.$_lang['rename'].'"></i></span>'; |
|
656 | + $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '<a href="javascript:deleteFile(\''.urlencode($file).'\');"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></a>' : '<span class="disabled"><i class="'.$_style['files_delete'].'" title="'.$_lang['file_delete_file'].'"></i></span>'; |
|
657 | 657 | |
658 | 658 | // increment the counter |
659 | 659 | $filecounter++; |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | for ($i = 0; $i < $folders; $i++) { |
667 | 667 | $filesizes += $dirs_array[$i]['stats']['7']; |
668 | 668 | echo '<tr>'; |
669 | - echo '<td>' . $dirs_array[$i]['text'] . '</td>'; |
|
670 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($dirs_array[$i]['stats']['9']) . '</td>'; |
|
671 | - echo '<td class="text-right">' . $modx->nicesize($dirs_array[$i]['stats']['7']) . '</td>'; |
|
669 | + echo '<td>'.$dirs_array[$i]['text'].'</td>'; |
|
670 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($dirs_array[$i]['stats']['9']).'</td>'; |
|
671 | + echo '<td class="text-right">'.$modx->nicesize($dirs_array[$i]['stats']['7']).'</td>'; |
|
672 | 672 | echo '<td class="actions text-right">'; |
673 | 673 | echo $dirs_array[$i]['rename']; |
674 | 674 | echo $dirs_array[$i]['delete']; |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | sort($files_array); // sorting the array alphabetically (Thanks pxl8r!) |
682 | 682 | for ($i = 0; $i < $files; $i++) { |
683 | 683 | $filesizes += $files_array[$i]['stats']['7']; |
684 | - echo '<tr ' . markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']) . '>'; |
|
685 | - echo '<td>' . $files_array[$i]['text'] . '</td>'; |
|
686 | - echo '<td class="text-nowrap">' . $modx->toDateFormat($files_array[$i]['stats']['9']) . '</td>'; |
|
687 | - echo '<td class="text-right">' . $modx->nicesize($files_array[$i]['stats']['7']) . '</td>'; |
|
684 | + echo '<tr '.markRow($files_array[$i]['file'], $_REQUEST['path'], $_REQUEST['mode']).'>'; |
|
685 | + echo '<td>'.$files_array[$i]['text'].'</td>'; |
|
686 | + echo '<td class="text-nowrap">'.$modx->toDateFormat($files_array[$i]['stats']['9']).'</td>'; |
|
687 | + echo '<td class="text-right">'.$modx->nicesize($files_array[$i]['stats']['7']).'</td>'; |
|
688 | 688 | echo '<td class="actions text-right">'; |
689 | 689 | echo $files_array[$i]['unzip']; |
690 | 690 | echo $files_array[$i]['view']; |
@@ -792,17 +792,17 @@ discard block |
||
792 | 792 | $zip = zip_open($file); |
793 | 793 | if ($zip) { |
794 | 794 | $old_umask = umask(0); |
795 | - $path = rtrim($path, '/') . '/'; |
|
795 | + $path = rtrim($path, '/').'/'; |
|
796 | 796 | while ($zip_entry = zip_read($zip)) { |
797 | 797 | if (zip_entry_filesize($zip_entry) > 0) { |
798 | 798 | // str_replace must be used under windows to convert "/" into "\" |
799 | 799 | $zip_entry_name = zip_entry_name($zip_entry); |
800 | - $complete_path = $path . str_replace('\\', '/', dirname($zip_entry_name)); |
|
801 | - $complete_name = $path . str_replace('\\', '/', $zip_entry_name); |
|
800 | + $complete_path = $path.str_replace('\\', '/', dirname($zip_entry_name)); |
|
801 | + $complete_name = $path.str_replace('\\', '/', $zip_entry_name); |
|
802 | 802 | if (!file_exists($complete_path)) { |
803 | 803 | $tmp = ''; |
804 | 804 | foreach (explode('/', $complete_path) AS $k) { |
805 | - $tmp .= $k . '/'; |
|
805 | + $tmp .= $k.'/'; |
|
806 | 806 | if (!is_dir($tmp)) { |
807 | 807 | mkdir($tmp, 0777); |
808 | 808 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | function rrmdir($dir) |
825 | 825 | { |
826 | - foreach (glob($dir . '/*') as $file) { |
|
826 | + foreach (glob($dir.'/*') as $file) { |
|
827 | 827 | if (is_dir($file)) { |
828 | 828 | rrmdir($file); |
829 | 829 | } else { |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | $msg = ''; |
840 | 840 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
841 | 841 | if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
842 | - $userfile= array(); |
|
842 | + $userfile = array(); |
|
843 | 843 | |
844 | 844 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
845 | 845 | $userfile['error'] = $_FILES['userfile']['error'][$i]; |
@@ -856,12 +856,12 @@ discard block |
||
856 | 856 | $userfile['type'] = $_FILES['userfile']['type'][$i]; |
857 | 857 | |
858 | 858 | // this seems to be an upload action. |
859 | - $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
860 | - $path = rtrim($path, '/') . '/' . $userfile['name']; |
|
859 | + $path = $modx->config['site_url'].substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
860 | + $path = rtrim($path, '/').'/'.$userfile['name']; |
|
861 | 861 | $msg .= $path; |
862 | 862 | if ($userfile['error'] == 0) { |
863 | - $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : ''; |
|
864 | - $msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '</p>'; |
|
863 | + $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="'.$path.'" height="75" />' : ''; |
|
864 | + $msg .= "<p>".$_lang['files_file_type'].$userfile['type'].", ".$modx->nicesize(filesize($userfile['tmp_name'])).$img.'</p>'; |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | $userfilename = $userfile['tmp_name']; |
@@ -869,15 +869,15 @@ discard block |
||
869 | 869 | if (is_uploaded_file($userfilename)) { |
870 | 870 | // file is uploaded file, process it! |
871 | 871 | if (!checkExtension($userfile['name'])) { |
872 | - $msg .= '<p><span class="warning">' . $_lang['files_filetype_notok'] . '</span></p>'; |
|
872 | + $msg .= '<p><span class="warning">'.$_lang['files_filetype_notok'].'</span></p>'; |
|
873 | 873 | } else { |
874 | - if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { |
|
874 | + if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'].'/'.$userfile['name'])) { |
|
875 | 875 | // Ryan: Repair broken permissions issue with file manager |
876 | 876 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
877 | - @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); |
|
877 | + @chmod($_POST['path']."/".$userfile['name'], $new_file_permissions); |
|
878 | 878 | } |
879 | 879 | // Ryan: End |
880 | - $msg .= '<p><span class="success">' . $_lang['files_upload_ok'] . '</span></p><hr/>'; |
|
880 | + $msg .= '<p><span class="success">'.$_lang['files_upload_ok'].'</span></p><hr/>'; |
|
881 | 881 | |
882 | 882 | // invoke OnFileManagerUpload event |
883 | 883 | $modx->invokeEvent('OnFileManagerUpload', array( |
@@ -885,13 +885,13 @@ discard block |
||
885 | 885 | 'filename' => $userfile['name'] |
886 | 886 | )); |
887 | 887 | // Log the change |
888 | - logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); |
|
888 | + logFileChange('upload', $_POST['path'].'/'.$userfile['name']); |
|
889 | 889 | } else { |
890 | - $msg .= '<p><span class="warning">' . $_lang['files_upload_copyfailed'] . '</span> ' . $_lang["files_upload_permissions_error"] . '</p>'; |
|
890 | + $msg .= '<p><span class="warning">'.$_lang['files_upload_copyfailed'].'</span> '.$_lang["files_upload_permissions_error"].'</p>'; |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } else { |
894 | - $msg .= '<br /><span class="warning"><b>' . $_lang['files_upload_error'] . ':</b>'; |
|
894 | + $msg .= '<br /><span class="warning"><b>'.$_lang['files_upload_error'].':</b>'; |
|
895 | 895 | switch ($userfile['error']) { |
896 | 896 | case 0: //no error; possible file attack! |
897 | 897 | $msg .= $_lang['files_upload_error0']; |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | $msg .= '</span><br />'; |
916 | 916 | } |
917 | 917 | } |
918 | - return $msg . '<br/>'; |
|
918 | + return $msg.'<br/>'; |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | function textsave() |
@@ -928,9 +928,9 @@ discard block |
||
928 | 928 | |
929 | 929 | // Write $content to our opened file. |
930 | 930 | if (file_put_contents($filename, $content) === false) { |
931 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_saved'] . '</b></span><br /><br />'; |
|
931 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_saved'].'</b></span><br /><br />'; |
|
932 | 932 | } else { |
933 | - $msg .= '<span class="success"><b>' . $_lang['file_saved'] . '</b></span><br /><br />'; |
|
933 | + $msg .= '<span class="success"><b>'.$_lang['file_saved'].'</b></span><br /><br />'; |
|
934 | 934 | $_REQUEST['mode'] = 'edit'; |
935 | 935 | } |
936 | 936 | // Log the change |
@@ -946,9 +946,9 @@ discard block |
||
946 | 946 | |
947 | 947 | $file = $_REQUEST['path']; |
948 | 948 | if (!$token_check || !@unlink($file)) { |
949 | - $msg .= '<span class="warning"><b>' . $_lang['file_not_deleted'] . '</b></span><br /><br />'; |
|
949 | + $msg .= '<span class="warning"><b>'.$_lang['file_not_deleted'].'</b></span><br /><br />'; |
|
950 | 950 | } else { |
951 | - $msg .= '<span class="success"><b>' . $_lang['file_deleted'] . '</b></span><br /><br />'; |
|
951 | + $msg .= '<span class="success"><b>'.$_lang['file_deleted'].'</b></span><br /><br />'; |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | // Log the change |
@@ -733,7 +733,8 @@ discard block |
||
733 | 733 | } |
734 | 734 | |
735 | 735 | function mkdirs($strPath, $mode) |
736 | -{ // recursive mkdir function |
|
736 | +{ |
|
737 | +// recursive mkdir function |
|
737 | 738 | if (is_dir($strPath)) { |
738 | 739 | return true; |
739 | 740 | } |
@@ -838,7 +839,9 @@ discard block |
||
838 | 839 | global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
839 | 840 | $msg = ''; |
840 | 841 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
841 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
842 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
843 | + continue; |
|
844 | + } |
|
842 | 845 | $userfile= array(); |
843 | 846 | |
844 | 847 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
@@ -160,6 +160,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,17 +1,17 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('import_static')) { |
|
5 | +if (!$modx->hasPermission('import_static')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | <div class="tab-page"> |
44 | 44 | <div class="container container-body"> |
45 | 45 | <?php |
46 | - if(!isset($_POST['import'])) { |
|
47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
46 | + if (!isset($_POST['import'])) { |
|
47 | + echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; |
|
48 | 48 | ?> |
49 | 49 | <form action="index.php" method="post" name="importFrm"> |
50 | 50 | <input type="hidden" name="import" value="import" /> |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | </div> |
102 | 102 | |
103 | 103 | <?php |
104 | -function run() { |
|
104 | +function run(){ |
|
105 | 105 | global $modx, $_lang; |
106 | 106 | |
107 | 107 | $tbl_site_content = $modx->getFullTableName('site_content'); |
108 | 108 | $output = ''; |
109 | 109 | $maxtime = $_POST['maxtime']; |
110 | 110 | |
111 | - if(!is_numeric($maxtime)) { |
|
111 | + if (!is_numeric($maxtime)) { |
|
112 | 112 | $maxtime = 30; |
113 | 113 | } |
114 | 114 | |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | $mtime = $mtime[1] + $mtime[0]; |
120 | 120 | $importstart = $mtime; |
121 | 121 | |
122 | - if($_POST['reset'] == 'on') { |
|
122 | + if ($_POST['reset'] == 'on') { |
|
123 | 123 | $modx->db->truncate($tbl_site_content); |
124 | 124 | $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
125 | 125 | } |
126 | 126 | |
127 | 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/'; |
|
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 | 133 | } else { |
134 | 134 | $filedir = ''; |
135 | 135 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | $files = pop_index($files); |
141 | 141 | |
142 | 142 | // no. of files to import |
143 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
143 | + $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound); |
|
144 | 144 | |
145 | 145 | // import files |
146 | - if(0 < count($files)) { |
|
146 | + if (0 < count($files)) { |
|
147 | 147 | $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
148 | 148 | importFiles($parent, $filedir, $files, 'root'); |
149 | 149 | } |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | $mtime = $mtime[1] + $mtime[0]; |
154 | 154 | $importend = $mtime; |
155 | 155 | $totaltime = ($importend - $importstart); |
156 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
156 | + $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3)); |
|
157 | 157 | |
158 | - if($_POST['convert_link'] == 'on') { |
|
158 | + if ($_POST['convert_link'] == 'on') { |
|
159 | 159 | convertLink(); |
160 | 160 | } |
161 | 161 | |
162 | 162 | return $output; |
163 | 163 | } |
164 | 164 | |
165 | -function importFiles($parent, $filedir, $files, $mode) { |
|
165 | +function importFiles($parent, $filedir, $files, $mode){ |
|
166 | 166 | global $modx; |
167 | 167 | global $_lang, $allowedfiles; |
168 | 168 | global $search_default, $cache_default, $publish_default; |
@@ -171,21 +171,21 @@ discard block |
||
171 | 171 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
172 | 172 | |
173 | 173 | $createdby = $modx->getLoginUserID(); |
174 | - if(!is_array($files)) { |
|
174 | + if (!is_array($files)) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | - if($_POST['object'] == 'all') { |
|
177 | + if ($_POST['object'] == 'all') { |
|
178 | 178 | $modx->config['default_template'] = '0'; |
179 | 179 | $richtext = '0'; |
180 | 180 | } else { |
181 | 181 | $richtext = '1'; |
182 | 182 | } |
183 | 183 | |
184 | - foreach($files as $id => $value) { |
|
185 | - if(is_array($value)) { |
|
184 | + foreach ($files as $id => $value) { |
|
185 | + if (is_array($value)) { |
|
186 | 186 | // create folder |
187 | 187 | $alias = $id; |
188 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
188 | + printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias); |
|
189 | 189 | $field = array(); |
190 | 190 | $field['type'] = 'document'; |
191 | 191 | $field['contentType'] = 'text/html'; |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | $field['isfolder'] = 1; |
201 | 201 | $field['menuindex'] = 1; |
202 | 202 | $find = false; |
203 | - foreach(array( |
|
203 | + foreach (array( |
|
204 | 204 | 'index.html', |
205 | 205 | 'index.htm' |
206 | 206 | ) as $filename) { |
207 | - $filepath = $filedir . $alias . '/' . $filename; |
|
208 | - if($find === false && file_exists($filepath)) { |
|
207 | + $filepath = $filedir.$alias.'/'.$filename; |
|
208 | + if ($find === false && file_exists($filepath)) { |
|
209 | 209 | $file = getFileContent($filepath); |
210 | 210 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
211 | 211 | |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | $field['createdon'] = $date; |
218 | 218 | $field['editedon'] = $date; |
219 | 219 | $newid = $modx->db->insert($field, $tbl_site_content); |
220 | - if($newid) { |
|
220 | + if ($newid) { |
|
221 | 221 | $find = true; |
222 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
223 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
222 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
223 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
224 | 224 | } else { |
225 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
225 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
226 | 226 | exit; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | - if($find === false) { |
|
230 | + if ($find === false) { |
|
231 | 231 | $date = time(); |
232 | 232 | $field['pagetitle'] = '---'; |
233 | 233 | $field['content'] = ''; |
@@ -235,30 +235,30 @@ discard block |
||
235 | 235 | $field['editedon'] = $date; |
236 | 236 | $field['hidemenu'] = '1'; |
237 | 237 | $newid = $modx->db->insert($field, $tbl_site_content); |
238 | - if($newid) { |
|
238 | + if ($newid) { |
|
239 | 239 | $find = true; |
240 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
241 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
240 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
241 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
242 | 242 | } else { |
243 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
243 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
244 | 244 | exit; |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } else { |
248 | 248 | // create document |
249 | - if($mode == 'sub' && $value == 'index.html') { |
|
249 | + if ($mode == 'sub' && $value == 'index.html') { |
|
250 | 250 | continue; |
251 | 251 | } |
252 | 252 | $filename = $value; |
253 | 253 | $fparts = explode('.', $value); |
254 | 254 | $alias = $fparts[0]; |
255 | 255 | $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
256 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
256 | + printf("<span>".$_lang['import_site_importing_document']."</span>", $filename); |
|
257 | 257 | |
258 | - if(!in_array($ext, $allowedfiles)) { |
|
259 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
258 | + if (!in_array($ext, $allowedfiles)) { |
|
259 | + echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n"; |
|
260 | 260 | } else { |
261 | - $filepath = $filedir . $filename; |
|
261 | + $filepath = $filedir.$filename; |
|
262 | 262 | $file = getFileContent($filepath); |
263 | 263 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
264 | 264 | |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | $field['isfolder'] = 0; |
284 | 284 | $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
285 | 285 | $newid = $modx->db->insert($field, $tbl_site_content); |
286 | - if($newid) { |
|
287 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
286 | + if ($newid) { |
|
287 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
288 | 288 | } else { |
289 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
289 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
290 | 290 | exit; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $is_site_start = false; |
294 | - if($filename == 'index.html') { |
|
294 | + if ($filename == 'index.html') { |
|
295 | 295 | $is_site_start = true; |
296 | 296 | } |
297 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
297 | + if ($is_site_start == true && $_POST['reset'] == 'on') { |
|
298 | 298 | $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
299 | 299 | $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
300 | 300 | } |
@@ -303,85 +303,85 @@ discard block |
||
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
306 | +function getFiles($directory, $listing = array(), $count = 0){ |
|
307 | 307 | global $_lang; |
308 | 308 | global $filesfound; |
309 | 309 | $dummy = $count; |
310 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
311 | - foreach($files as $file) { |
|
312 | - if($file == '.' || $file == '..') { |
|
310 | + if (!empty($directory) && $files = scandir($directory)) { |
|
311 | + foreach ($files as $file) { |
|
312 | + if ($file == '.' || $file == '..') { |
|
313 | 313 | continue; |
314 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
314 | + } elseif ($h = @opendir($directory.$file."/")) { |
|
315 | 315 | closedir($h); |
316 | 316 | $count = -1; |
317 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
318 | - } elseif(strpos($file, '.htm') !== false) { |
|
317 | + $listing[$file] = getFiles($directory.$file."/", array(), $count + 1); |
|
318 | + } elseif (strpos($file, '.htm') !== false) { |
|
319 | 319 | $listing[$dummy] = $file; |
320 | 320 | $dummy = $dummy + 1; |
321 | 321 | $filesfound++; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | } else { |
325 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
325 | + echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>"; |
|
326 | 326 | } |
327 | 327 | return ($listing); |
328 | 328 | } |
329 | 329 | |
330 | -function getFileContent($filepath) { |
|
330 | +function getFileContent($filepath){ |
|
331 | 331 | global $_lang; |
332 | 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>"; |
|
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 | 335 | } else { |
336 | 336 | return $buffer; |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | -function pop_index($array) { |
|
340 | +function pop_index($array){ |
|
341 | 341 | $new_array = array(); |
342 | - foreach($array as $k => $v) { |
|
343 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
342 | + foreach ($array as $k => $v) { |
|
343 | + if ($v !== 'index.html' && $v !== 'index.htm') { |
|
344 | 344 | $new_array[$k] = $v; |
345 | 345 | } else { |
346 | 346 | array_unshift($new_array, $v); |
347 | 347 | } |
348 | 348 | } |
349 | - foreach($array as $k => $v) { |
|
350 | - if(is_array($v)) { |
|
349 | + foreach ($array as $k => $v) { |
|
350 | + if (is_array($v)) { |
|
351 | 351 | $new_array[$k] = $v; |
352 | 352 | } |
353 | 353 | } |
354 | 354 | return $new_array; |
355 | 355 | } |
356 | 356 | |
357 | -function treatContent($src, $filename, $alias) { |
|
357 | +function treatContent($src, $filename, $alias){ |
|
358 | 358 | global $modx; |
359 | 359 | |
360 | 360 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
361 | 361 | |
362 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
362 | + if (preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
363 | 363 | $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
364 | 364 | $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
365 | 365 | } else { |
366 | 366 | $pagetitle = $alias; |
367 | 367 | } |
368 | - if(!$pagetitle) { |
|
368 | + if (!$pagetitle) { |
|
369 | 369 | $pagetitle = $alias; |
370 | 370 | } |
371 | 371 | |
372 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
372 | + if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
373 | 373 | $description = ($matches[1] !== '') ? $matches[1] : $filename; |
374 | 374 | $description = str_replace('[*description*]', '', $description); |
375 | 375 | } else { |
376 | 376 | $description = ''; |
377 | 377 | } |
378 | 378 | |
379 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
379 | + if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
380 | 380 | $content = $matches[1]; |
381 | 381 | } else { |
382 | 382 | $content = $src; |
383 | 383 | $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
384 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
384 | + $r = '$1'.$modx->config['modx_charset'].'$2'; |
|
385 | 385 | $content = preg_replace($s, $r, $content); |
386 | 386 | $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
387 | 387 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
398 | -function convertLink() { |
|
398 | +function convertLink(){ |
|
399 | 399 | global $modx; |
400 | 400 | $tbl_site_content = $modx->getFullTableName('site_content'); |
401 | 401 | |
@@ -403,33 +403,33 @@ discard block |
||
403 | 403 | $p = array(); |
404 | 404 | $target = array(); |
405 | 405 | $dir = ''; |
406 | - while($row = $modx->db->getRow($rs)) { |
|
406 | + while ($row = $modx->db->getRow($rs)) { |
|
407 | 407 | $id = $row['id']; |
408 | 408 | $array = explode('<a href=', $row['content']); |
409 | 409 | $c = 0; |
410 | - foreach($array as $v) { |
|
411 | - if($v[0] === '"') { |
|
410 | + foreach ($array as $v) { |
|
411 | + if ($v[0] === '"') { |
|
412 | 412 | $v = substr($v, 1); |
413 | 413 | list($href, $v) = explode('"', $v, 2); |
414 | 414 | $_ = $href; |
415 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
416 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
415 | + if (strpos($_, $modx->config['site_url']) !== false) { |
|
416 | + $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_); |
|
417 | 417 | } |
418 | - if($_[0] === '/') { |
|
418 | + if ($_[0] === '/') { |
|
419 | 419 | $_ = substr($_, 1); |
420 | 420 | } |
421 | 421 | $_ = str_replace('/index.html', '.html', $_); |
422 | 422 | $level = substr_count($_, '../'); |
423 | - if(1 < $level) { |
|
424 | - if(!isset($p[$id])) { |
|
423 | + if (1 < $level) { |
|
424 | + if (!isset($p[$id])) { |
|
425 | 425 | $p[$id] = $modx->getParentIds($id); |
426 | 426 | } |
427 | 427 | $k = array_keys($p[$id]); |
428 | - while(0 < $level) { |
|
428 | + while (0 < $level) { |
|
429 | 429 | $dir = array_shift($k); |
430 | 430 | $level--; |
431 | 431 | } |
432 | - if($dir != '') { |
|
432 | + if ($dir != '') { |
|
433 | 433 | $dir .= '/'; |
434 | 434 | } |
435 | 435 | } else { |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | $_ = trim($_, './'); |
440 | - if(strpos($_, '/') !== false) { |
|
440 | + if (strpos($_, '/') !== false) { |
|
441 | 441 | $_ = substr($_, strrpos($_, '/')); |
442 | 442 | } |
443 | - $_ = $dir . str_replace('.html', '', $_); |
|
444 | - if(!isset($target[$_])) { |
|
443 | + $_ = $dir.str_replace('.html', '', $_); |
|
444 | + if (!isset($target[$_])) { |
|
445 | 445 | $target[$_] = $modx->getIdFromAlias($_); |
446 | 446 | } |
447 | 447 | $target[$_] = trim($target[$_]); |
448 | - if(!empty($target[$_])) { |
|
449 | - $href = '[~' . $target[$_] . '~]'; |
|
448 | + if (!empty($target[$_])) { |
|
449 | + $href = '[~'.$target[$_].'~]'; |
|
450 | 450 | } |
451 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
451 | + $array[$c] = '<a href="'.$href.'"'.$v; |
|
452 | 452 | } |
453 | 453 | $c++; |
454 | 454 | } |
@@ -101,7 +101,8 @@ discard block |
||
101 | 101 | </div> |
102 | 102 | |
103 | 103 | <?php |
104 | -function run() { |
|
104 | +function run() |
|
105 | +{ |
|
105 | 106 | global $modx, $_lang; |
106 | 107 | |
107 | 108 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -162,7 +163,8 @@ discard block |
||
162 | 163 | return $output; |
163 | 164 | } |
164 | 165 | |
165 | -function importFiles($parent, $filedir, $files, $mode) { |
|
166 | +function importFiles($parent, $filedir, $files, $mode) |
|
167 | +{ |
|
166 | 168 | global $modx; |
167 | 169 | global $_lang, $allowedfiles; |
168 | 170 | global $search_default, $cache_default, $publish_default; |
@@ -303,7 +305,8 @@ discard block |
||
303 | 305 | } |
304 | 306 | } |
305 | 307 | |
306 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
308 | +function getFiles($directory, $listing = array(), $count = 0) |
|
309 | +{ |
|
307 | 310 | global $_lang; |
308 | 311 | global $filesfound; |
309 | 312 | $dummy = $count; |
@@ -327,7 +330,8 @@ discard block |
||
327 | 330 | return ($listing); |
328 | 331 | } |
329 | 332 | |
330 | -function getFileContent($filepath) { |
|
333 | +function getFileContent($filepath) |
|
334 | +{ |
|
331 | 335 | global $_lang; |
332 | 336 | // get the file |
333 | 337 | if(!$buffer = file_get_contents($filepath)) { |
@@ -337,7 +341,8 @@ discard block |
||
337 | 341 | } |
338 | 342 | } |
339 | 343 | |
340 | -function pop_index($array) { |
|
344 | +function pop_index($array) |
|
345 | +{ |
|
341 | 346 | $new_array = array(); |
342 | 347 | foreach($array as $k => $v) { |
343 | 348 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -354,7 +359,8 @@ discard block |
||
354 | 359 | return $new_array; |
355 | 360 | } |
356 | 361 | |
357 | -function treatContent($src, $filename, $alias) { |
|
362 | +function treatContent($src, $filename, $alias) |
|
363 | +{ |
|
358 | 364 | global $modx; |
359 | 365 | |
360 | 366 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -395,7 +401,8 @@ discard block |
||
395 | 401 | ); |
396 | 402 | } |
397 | 403 | |
398 | -function convertLink() { |
|
404 | +function convertLink() |
|
405 | +{ |
|
399 | 406 | global $modx; |
400 | 407 | $tbl_site_content = $modx->getFullTableName('site_content'); |
401 | 408 |
@@ -504,6 +504,9 @@ |
||
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 |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | * @param $theme |
11 | 11 | * @param string $hereid |
12 | 12 | */ |
13 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
13 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
14 | +{ |
|
14 | 15 | global $modx; |
15 | 16 | global $icons, $iconsPrivate, $_style; |
16 | 17 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -450,7 +451,8 @@ discard block |
||
450 | 451 | return $output; |
451 | 452 | } |
452 | 453 | |
453 | -function getIconInfo($_style) { |
|
454 | +function getIconInfo($_style) |
|
455 | +{ |
|
454 | 456 | if(!isset($_style['tree_page_gif'])) { |
455 | 457 | $_style['tree_page_gif'] = $_style['tree_page']; |
456 | 458 | } |
@@ -477,7 +479,8 @@ discard block |
||
477 | 479 | return $icons; |
478 | 480 | } |
479 | 481 | |
480 | -function getPrivateIconInfo($_style) { |
|
482 | +function getPrivateIconInfo($_style) |
|
483 | +{ |
|
481 | 484 | if(!isset($_style['tree_page_gif_secure'])) { |
482 | 485 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
483 | 486 | } |
@@ -504,7 +507,8 @@ discard block |
||
504 | 507 | return $iconsPrivate; |
505 | 508 | } |
506 | 509 | |
507 | -function getNodeTitle($nodeNameSource, $row) { |
|
510 | +function getNodeTitle($nodeNameSource, $row) |
|
511 | +{ |
|
508 | 512 | global $modx; |
509 | 513 | |
510 | 514 | switch($nodeNameSource) { |
@@ -550,7 +554,8 @@ discard block |
||
550 | 554 | return $nodetitle; |
551 | 555 | } |
552 | 556 | |
553 | -function isDateNode($nodeNameSource) { |
|
557 | +function isDateNode($nodeNameSource) |
|
558 | +{ |
|
554 | 559 | switch($nodeNameSource) { |
555 | 560 | case 'createdon': |
556 | 561 | case 'editedon': |
@@ -563,13 +568,15 @@ discard block |
||
563 | 568 | } |
564 | 569 | } |
565 | 570 | |
566 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
571 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
572 | +{ |
|
567 | 573 | global $modx; |
568 | 574 | |
569 | 575 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
570 | 576 | } |
571 | 577 | |
572 | -function _htmlentities($array) { |
|
578 | +function _htmlentities($array) |
|
579 | +{ |
|
573 | 580 | global $modx; |
574 | 581 | |
575 | 582 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -578,7 +585,8 @@ discard block |
||
578 | 585 | return $array; |
579 | 586 | } |
580 | 587 | |
581 | -function getTplSingleNode() { |
|
588 | +function getTplSingleNode() |
|
589 | +{ |
|
582 | 590 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
583 | 591 | onclick="modx.tree.treeAction(event,[+id+]);" |
584 | 592 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -602,7 +610,8 @@ discard block |
||
602 | 610 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a></div>'; |
603 | 611 | } |
604 | 612 | |
605 | -function getTplFolderNode() { |
|
613 | +function getTplFolderNode() |
|
614 | +{ |
|
606 | 615 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
607 | 616 | onclick="modx.tree.treeAction(event,[+id+]);" |
608 | 617 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -638,7 +647,8 @@ discard block |
||
638 | 647 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
639 | 648 | } |
640 | 649 | |
641 | -function getTplFolderNodeNotChildren() { |
|
650 | +function getTplFolderNodeNotChildren() |
|
651 | +{ |
|
642 | 652 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
643 | 653 | onclick="modx.tree.treeAction(event,[+id+]);" |
644 | 654 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -670,7 +680,8 @@ discard block |
||
670 | 680 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
671 | 681 | } |
672 | 682 | |
673 | -function dbug($str, $flag = false) { |
|
683 | +function dbug($str, $flag = false) |
|
684 | +{ |
|
674 | 685 | print('<pre>'); |
675 | 686 | print_r($str); |
676 | 687 | print('</pre>'); |
@@ -1,6 +1,6 @@ discard block |
||
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 |
||
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 <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(' %s', $_style['tree_linkgo']) : ''; |
|
110 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $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+]', ' ', $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 <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(' %s', $_style['tree_linkgo']) : ''; |
|
110 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $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+]', ' ', $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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
4 | 4 | } |
5 | 5 | |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @param $theme |
11 | 11 | * @param string $hereid |
12 | 12 | */ |
13 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
13 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = ''){ |
|
14 | 14 | global $modx; |
15 | 15 | global $icons, $iconsPrivate, $_style; |
16 | 16 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | // setup spacer |
22 | 22 | $level = 0; |
23 | 23 | $spacer = '<span class="indent">'; |
24 | - for($i = 2; $i <= $indent; $i++) { |
|
24 | + for ($i = 2; $i <= $indent; $i++) { |
|
25 | 25 | $spacer .= '<i></i>'; |
26 | 26 | $level++; |
27 | 27 | } |
28 | 28 | $spacer .= '</span>'; |
29 | 29 | |
30 | 30 | // manage order-by |
31 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
31 | + if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
32 | 32 | // This is the first startup, set default sort order |
33 | 33 | $_SESSION['tree_sortby'] = 'menuindex'; |
34 | 34 | $_SESSION['tree_sortdir'] = 'ASC'; |
35 | 35 | } |
36 | 36 | |
37 | - switch($_SESSION['tree_sortby']) { |
|
37 | + switch ($_SESSION['tree_sortby']) { |
|
38 | 38 | case 'createdon': |
39 | 39 | case 'editedon': |
40 | 40 | case 'publishedon': |
41 | 41 | case 'pub_date': |
42 | 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']); |
|
43 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
44 | 44 | break; |
45 | 45 | default: |
46 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
46 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
47 | 47 | }; |
48 | 48 | |
49 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
49 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
50 | 50 | |
51 | 51 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
52 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
52 | + if ($_SESSION['tree_sortby'] == 'isfolder') { |
|
53 | 53 | $orderby .= ', menuindex ASC, pagetitle'; |
54 | 54 | } |
55 | 55 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | // get document groups for current user |
60 | 60 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
61 | 61 | $showProtected = false; |
62 | - if(isset ($modx->config['tree_show_protected'])) { |
|
62 | + if (isset ($modx->config['tree_show_protected'])) { |
|
63 | 63 | $showProtected = (boolean) $modx->config['tree_show_protected']; |
64 | 64 | } |
65 | 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}))"); |
|
66 | + if ($showProtected == false) { |
|
67 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
68 | 68 | } else { |
69 | 69 | $access = ''; |
70 | 70 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
75 | 75 | $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
76 | 76 | $result = $modx->db->select($field, $from, $where, $orderby); |
77 | - if($modx->db->getRecordCount($result) == 0) { |
|
77 | + if ($modx->db->getRecordCount($result) == 0) { |
|
78 | 78 | $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
82 | 82 | |
83 | - while($row = $modx->db->getRow($result)) { |
|
83 | + while ($row = $modx->db->getRow($result)) { |
|
84 | 84 | $node = ''; |
85 | 85 | |
86 | 86 | $nodetitle = getNodeTitle($nodeNameSource, $row); |
@@ -89,46 +89,46 @@ discard block |
||
89 | 89 | $treeNodeClass = 'node'; |
90 | 90 | $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
91 | 91 | |
92 | - if($row['deleted'] == 1) { |
|
92 | + if ($row['deleted'] == 1) { |
|
93 | 93 | $treeNodeClass .= ' deleted'; |
94 | 94 | //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
95 | - } elseif($row['published'] == 0) { |
|
95 | + } elseif ($row['published'] == 0) { |
|
96 | 96 | $treeNodeClass .= ' unpublished'; |
97 | 97 | //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
98 | - } elseif($row['hidemenu'] == 1) { |
|
98 | + } elseif ($row['hidemenu'] == 1) { |
|
99 | 99 | $treeNodeClass .= ' hidemenu'; |
100 | 100 | //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
101 | 101 | } else { |
102 | 102 | //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
103 | 103 | } |
104 | 104 | |
105 | - if($row['id'] == $hereid) { |
|
105 | + if ($row['id'] == $hereid) { |
|
106 | 106 | $treeNodeClass .= ' current'; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
110 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
110 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
111 | 111 | |
112 | 112 | // Prepare displaying user-locks |
113 | 113 | $lockedByUser = ''; |
114 | 114 | $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
115 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
116 | - if($rowLock['sid'] == $modx->sid) { |
|
115 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
116 | + if ($rowLock['sid'] == $modx->sid) { |
|
117 | 117 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
118 | 118 | 'element_type' => $_lang["lock_element_type_7"], |
119 | 119 | 'lasthit_df' => $rowLock['lasthit_df'] |
120 | 120 | )); |
121 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
121 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
122 | 122 | } else { |
123 | 123 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
124 | 124 | 'element_type' => $_lang["lock_element_type_7"], |
125 | 125 | 'username' => $rowLock['username'], |
126 | 126 | 'lasthit_df' => $rowLock['lasthit_df'] |
127 | 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>'; |
|
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 | 130 | } else { |
131 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
131 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -136,23 +136,23 @@ discard block |
||
136 | 136 | $url = $modx->makeUrl($row['id']); |
137 | 137 | |
138 | 138 | $title = ''; |
139 | - if(isDateNode($nodeNameSource)) { |
|
140 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
139 | + if (isDateNode($nodeNameSource)) { |
|
140 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
141 | 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']); |
|
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 | 154 | $title = $modx->htmlspecialchars($title); |
155 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
155 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
156 | 156 | |
157 | 157 | $data = array( |
158 | 158 | 'id' => $row['id'], |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | $ph['expandAll'] = $expandAll; |
202 | 202 | $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
203 | 203 | |
204 | - if(!$row['isfolder']) { |
|
204 | + if (!$row['isfolder']) { |
|
205 | 205 | $tpl = getTplSingleNode(); |
206 | - switch($row['id']) { |
|
206 | + switch ($row['id']) { |
|
207 | 207 | case $modx->config['site_start'] : |
208 | 208 | $icon = $_style['tree_page_home']; |
209 | 209 | break; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $icon = $_style['tree_page_info']; |
218 | 218 | break; |
219 | 219 | default: |
220 | - if(isset($icons[$row['contentType']])) { |
|
220 | + if (isset($icons[$row['contentType']])) { |
|
221 | 221 | $icon = $icons[$row['contentType']]; |
222 | 222 | } else { |
223 | 223 | $icon = $_style['tree_page']; |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | |
228 | 228 | // invoke OnManagerNodePrerender event |
229 | 229 | $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
230 | - if(is_array($prenode)) { |
|
230 | + if (is_array($prenode)) { |
|
231 | 231 | $phnew = array(); |
232 | - foreach($prenode as $pnode) { |
|
232 | + foreach ($prenode as $pnode) { |
|
233 | 233 | $phnew = array_merge($phnew, unserialize($pnode)); |
234 | 234 | } |
235 | 235 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
236 | 236 | } |
237 | 237 | |
238 | - if($ph['contextmenu']) { |
|
239 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
238 | + if ($ph['contextmenu']) { |
|
239 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
240 | 240 | } |
241 | 241 | |
242 | - if($_SESSION['tree_show_only_folders']) { |
|
243 | - if($row['parent'] == 0) { |
|
242 | + if ($_SESSION['tree_show_only_folders']) { |
|
243 | + if ($row['parent'] == 0) { |
|
244 | 244 | $node .= $modx->parseText($tpl, $ph); |
245 | 245 | } else { |
246 | 246 | $node .= ''; |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
254 | 254 | $ph['icon_folder_close'] = $_style['tree_folder_new']; |
255 | 255 | |
256 | - if($_SESSION['tree_show_only_folders']) { |
|
256 | + if ($_SESSION['tree_show_only_folders']) { |
|
257 | 257 | $tpl = getTplFolderNodeNotChildren(); |
258 | 258 | $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
259 | 259 | $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
260 | 260 | $ph['tree_page_click'] = 3; |
261 | 261 | |
262 | 262 | // expandAll: two type for partial expansion |
263 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
264 | - if($expandAll == 1) { |
|
263 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
264 | + if ($expandAll == 1) { |
|
265 | 265 | $opened2[] = $row['id']; |
266 | 266 | } |
267 | 267 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | $ph['node_toggle'] = 1; |
270 | 270 | $ph['subMenuState'] = ' open'; |
271 | 271 | |
272 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
272 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
273 | 273 | $ph['showChildren'] = 1; |
274 | 274 | $ph['icon_node_toggle'] = ''; |
275 | 275 | $ph['icon'] = $ph['icon_folder_close']; |
276 | - } elseif(!$checkDocs && $checkFolders) { |
|
276 | + } elseif (!$checkDocs && $checkFolders) { |
|
277 | 277 | $ph['showChildren'] = 0; |
278 | 278 | $ph['openFolder'] = 2; |
279 | 279 | } else { |
@@ -285,20 +285,20 @@ discard block |
||
285 | 285 | 'ph' => $ph, |
286 | 286 | 'opened' => '1' |
287 | 287 | )); |
288 | - if(is_array($prenode)) { |
|
288 | + if (is_array($prenode)) { |
|
289 | 289 | $phnew = array(); |
290 | - foreach($prenode as $pnode) { |
|
290 | + foreach ($prenode as $pnode) { |
|
291 | 291 | $phnew = array_merge($phnew, unserialize($pnode)); |
292 | 292 | } |
293 | 293 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
294 | 294 | } |
295 | 295 | |
296 | - if($ph['contextmenu']) { |
|
297 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
296 | + if ($ph['contextmenu']) { |
|
297 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | $node .= $modx->parseText($tpl, $ph); |
301 | - if($checkFolders) { |
|
301 | + if ($checkFolders) { |
|
302 | 302 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
303 | 303 | } |
304 | 304 | $node .= '</div></div>'; |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
309 | 309 | $ph['node_toggle'] = 0; |
310 | 310 | |
311 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
311 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
312 | 312 | $ph['showChildren'] = 1; |
313 | 313 | $ph['icon_node_toggle'] = ''; |
314 | - } elseif(!$checkDocs && $checkFolders) { |
|
314 | + } elseif (!$checkDocs && $checkFolders) { |
|
315 | 315 | $ph['showChildren'] = 0; |
316 | 316 | $ph['openFolder'] = 2; |
317 | 317 | } else { |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | 'ph' => $ph, |
324 | 324 | 'opened' => '0' |
325 | 325 | )); |
326 | - if(is_array($prenode)) { |
|
326 | + if (is_array($prenode)) { |
|
327 | 327 | $phnew = array(); |
328 | - foreach($prenode as $pnode) { |
|
328 | + foreach ($prenode as $pnode) { |
|
329 | 329 | $phnew = array_merge($phnew, unserialize($pnode)); |
330 | 330 | } |
331 | 331 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
332 | 332 | } |
333 | 333 | |
334 | - if($ph['contextmenu']) { |
|
335 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
334 | + if ($ph['contextmenu']) { |
|
335 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | $node .= $modx->parseText($tpl, $ph); |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | } else { |
342 | 342 | $tpl = getTplFolderNode(); |
343 | 343 | // expandAll: two type for partial expansion |
344 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
345 | - if($expandAll == 1) { |
|
344 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
345 | + if ($expandAll == 1) { |
|
346 | 346 | $opened2[] = $row['id']; |
347 | 347 | } |
348 | 348 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $ph['node_toggle'] = 1; |
351 | 351 | $ph['subMenuState'] = ' open'; |
352 | 352 | |
353 | - if($ph['donthit'] == 1) { |
|
353 | + if ($ph['donthit'] == 1) { |
|
354 | 354 | $ph['tree_page_click'] = 3; |
355 | 355 | $ph['icon_node_toggle'] = ''; |
356 | 356 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -362,32 +362,32 @@ discard block |
||
362 | 362 | 'ph' => $ph, |
363 | 363 | 'opened' => '1' |
364 | 364 | )); |
365 | - if(is_array($prenode)) { |
|
365 | + if (is_array($prenode)) { |
|
366 | 366 | $phnew = array(); |
367 | - foreach($prenode as $pnode) { |
|
367 | + foreach ($prenode as $pnode) { |
|
368 | 368 | $phnew = array_merge($phnew, unserialize($pnode)); |
369 | 369 | } |
370 | 370 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
371 | - if($ph['showChildren'] == 0) { |
|
371 | + if ($ph['showChildren'] == 0) { |
|
372 | 372 | unset($opened2[$row['id']]); |
373 | 373 | $ph['node_toggle'] = 0; |
374 | 374 | $ph['subMenuState'] = ''; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - if($ph['showChildren'] == 0) { |
|
378 | + if ($ph['showChildren'] == 0) { |
|
379 | 379 | $ph['icon_node_toggle'] = ''; |
380 | 380 | $ph['donthit'] = 1; |
381 | 381 | $ph['icon'] = $ph['icon_folder_close']; |
382 | 382 | $tpl = getTplFolderNodeNotChildren(); |
383 | 383 | } |
384 | 384 | |
385 | - if($ph['contextmenu']) { |
|
386 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
385 | + if ($ph['contextmenu']) { |
|
386 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $node .= $modx->parseText($tpl, $ph); |
390 | - if($ph['donthit'] == 0) { |
|
390 | + if ($ph['donthit'] == 0) { |
|
391 | 391 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
392 | 392 | } |
393 | 393 | $node .= '</div></div>'; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
398 | 398 | $ph['node_toggle'] = 0; |
399 | 399 | |
400 | - if($ph['donthit'] == 1) { |
|
400 | + if ($ph['donthit'] == 1) { |
|
401 | 401 | $ph['tree_page_click'] = 3; |
402 | 402 | $ph['icon_node_toggle'] = ''; |
403 | 403 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -409,23 +409,23 @@ discard block |
||
409 | 409 | 'ph' => $ph, |
410 | 410 | 'opened' => '0' |
411 | 411 | )); |
412 | - if(is_array($prenode)) { |
|
412 | + if (is_array($prenode)) { |
|
413 | 413 | $phnew = array(); |
414 | - foreach($prenode as $pnode) { |
|
414 | + foreach ($prenode as $pnode) { |
|
415 | 415 | $phnew = array_merge($phnew, unserialize($pnode)); |
416 | 416 | } |
417 | 417 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
418 | 418 | } |
419 | 419 | |
420 | - if($ph['showChildren'] == 0) { |
|
420 | + if ($ph['showChildren'] == 0) { |
|
421 | 421 | $ph['icon_node_toggle'] = ''; |
422 | 422 | $ph['donthit'] = 1; |
423 | 423 | $ph['icon'] = $ph['icon_folder_close']; |
424 | 424 | $tpl = getTplFolderNodeNotChildren(); |
425 | 425 | } |
426 | 426 | |
427 | - if($ph['contextmenu']) { |
|
428 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
427 | + if ($ph['contextmenu']) { |
|
428 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $node .= $modx->parseText($tpl, $ph); |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | // invoke OnManagerNodeRender event |
438 | 438 | $data['node'] = $node; |
439 | 439 | $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
440 | - if(is_array($evtOut)) { |
|
440 | + if (is_array($evtOut)) { |
|
441 | 441 | $evtOut = implode("\n", $evtOut); |
442 | 442 | } |
443 | - if($evtOut != '') { |
|
443 | + if ($evtOut != '') { |
|
444 | 444 | $node = trim($evtOut); |
445 | 445 | } |
446 | 446 | |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | return $output; |
451 | 451 | } |
452 | 452 | |
453 | -function getIconInfo($_style) { |
|
454 | - if(!isset($_style['tree_page_gif'])) { |
|
453 | +function getIconInfo($_style){ |
|
454 | + if (!isset($_style['tree_page_gif'])) { |
|
455 | 455 | $_style['tree_page_gif'] = $_style['tree_page']; |
456 | 456 | } |
457 | - if(!isset($_style['tree_page_jpg'])) { |
|
457 | + if (!isset($_style['tree_page_jpg'])) { |
|
458 | 458 | $_style['tree_page_jpg'] = $_style['tree_page']; |
459 | 459 | } |
460 | - if(!isset($_style['tree_page_png'])) { |
|
460 | + if (!isset($_style['tree_page_png'])) { |
|
461 | 461 | $_style['tree_page_png'] = $_style['tree_page']; |
462 | 462 | } |
463 | 463 | $icons = array( |
@@ -477,14 +477,14 @@ discard block |
||
477 | 477 | return $icons; |
478 | 478 | } |
479 | 479 | |
480 | -function getPrivateIconInfo($_style) { |
|
481 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
480 | +function getPrivateIconInfo($_style){ |
|
481 | + if (!isset($_style['tree_page_gif_secure'])) { |
|
482 | 482 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
483 | 483 | } |
484 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
484 | + if (!isset($_style['tree_page_jpg_secure'])) { |
|
485 | 485 | $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
486 | 486 | } |
487 | - if(!isset($_style['tree_page_png_secure'])) { |
|
487 | + if (!isset($_style['tree_page_png_secure'])) { |
|
488 | 488 | $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
489 | 489 | } |
490 | 490 | $iconsPrivate = array( |
@@ -504,21 +504,21 @@ discard block |
||
504 | 504 | return $iconsPrivate; |
505 | 505 | } |
506 | 506 | |
507 | -function getNodeTitle($nodeNameSource, $row) { |
|
507 | +function getNodeTitle($nodeNameSource, $row){ |
|
508 | 508 | global $modx; |
509 | 509 | |
510 | - switch($nodeNameSource) { |
|
510 | + switch ($nodeNameSource) { |
|
511 | 511 | case 'menutitle': |
512 | 512 | $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
513 | 513 | break; |
514 | 514 | case 'alias': |
515 | 515 | $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
516 | - if(strpos($row['alias'], '.') === false) { |
|
517 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
516 | + if (strpos($row['alias'], '.') === false) { |
|
517 | + if ($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
518 | 518 | $nodetitle .= $modx->config['friendly_url_suffix']; |
519 | 519 | } |
520 | 520 | } |
521 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
521 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
522 | 522 | break; |
523 | 523 | case 'pagetitle': |
524 | 524 | $nodetitle = $row['pagetitle']; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | case 'unpub_date': |
534 | 534 | $doc = $modx->getDocumentObject('id', $row['id']); |
535 | 535 | $date = $doc[$nodeNameSource]; |
536 | - if(!empty($date)) { |
|
536 | + if (!empty($date)) { |
|
537 | 537 | $nodetitle = $modx->toDateFormat($date); |
538 | 538 | } else { |
539 | 539 | $nodetitle = '- - -'; |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | return $nodetitle; |
551 | 551 | } |
552 | 552 | |
553 | -function isDateNode($nodeNameSource) { |
|
554 | - switch($nodeNameSource) { |
|
553 | +function isDateNode($nodeNameSource){ |
|
554 | + switch ($nodeNameSource) { |
|
555 | 555 | case 'createdon': |
556 | 556 | case 'editedon': |
557 | 557 | case 'publishedon': |
@@ -563,13 +563,13 @@ discard block |
||
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
566 | +function checkIsFolder($parent = 0, $isfolder = 1){ |
|
567 | 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 | -function _htmlentities($array) { |
|
572 | +function _htmlentities($array){ |
|
573 | 573 | global $modx; |
574 | 574 | |
575 | 575 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | return $array; |
579 | 579 | } |
580 | 580 | |
581 | -function getTplSingleNode() { |
|
581 | +function getTplSingleNode(){ |
|
582 | 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+]\');" |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a></div>'; |
603 | 603 | } |
604 | 604 | |
605 | -function getTplFolderNode() { |
|
605 | +function getTplFolderNode(){ |
|
606 | 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+]\');" |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
639 | 639 | } |
640 | 640 | |
641 | -function getTplFolderNodeNotChildren() { |
|
641 | +function getTplFolderNodeNotChildren(){ |
|
642 | 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+]\');" |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | title="[+title+]">[+nodetitleDisplay+][+weblinkDisplay+]</span>[+pageIdDisplay+]</a><div>'; |
671 | 671 | } |
672 | 672 | |
673 | -function dbug($str, $flag = false) { |
|
673 | +function dbug($str, $flag = false){ |
|
674 | 674 | print('<pre>'); |
675 | 675 | print_r($str); |
676 | 676 | print('</pre>'); |
677 | - if($flag) { |
|
677 | + if ($flag) { |
|
678 | 678 | exit; |
679 | 679 | } |
680 | 680 | } |
@@ -3,6 +3,9 @@ |
||
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'); |
@@ -19,9 +19,9 @@ discard block |
||
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 |
||
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; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | //Kyle Jaebker - 08/07/06 |
4 | 4 | |
5 | 5 | //Create a new category |
6 | -function newCategory($newCat) { |
|
6 | +function newCategory($newCat){ |
|
7 | 7 | global $modx; |
8 | 8 | $useTable = $modx->getFullTableName('categories'); |
9 | 9 | $categoryId = $modx->db->insert( |
@@ -14,36 +14,36 @@ discard block |
||
14 | 14 | return $categoryId; |
15 | 15 | } |
16 | 16 | //check if new category already exists |
17 | -function checkCategory($newCat = '') { |
|
17 | +function checkCategory($newCat = ''){ |
|
18 | 18 | global $modx; |
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)) { |
|
22 | + if ($cat = $modx->db->getValue($cats)) { |
|
23 | 23 | return $cat; |
24 | 24 | } |
25 | 25 | return 0; |
26 | 26 | } |
27 | 27 | //Check for category, create new if not exists |
28 | -function getCategory($category='') { |
|
28 | +function getCategory($category = ''){ |
|
29 | 29 | $categoryId = checkCategory($category); |
30 | - if(!$categoryId) $categoryId = newCategory($category); |
|
30 | + if (!$categoryId) $categoryId = newCategory($category); |
|
31 | 31 | return $categoryId; |
32 | 32 | } |
33 | 33 | //Get all categories |
34 | -function getCategories() { |
|
34 | +function getCategories(){ |
|
35 | 35 | global $modx; |
36 | 36 | $useTable = $modx->getFullTableName('categories'); |
37 | 37 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
38 | 38 | $resourceArray = array(); |
39 | - while($row = $modx->db->getRow($cats)) { |
|
39 | + while ($row = $modx->db->getRow($cats)) { |
|
40 | 40 | $row['category'] = stripslashes($row['category']); |
41 | 41 | $resourceArray[] = $row; |
42 | 42 | } |
43 | 43 | return $resourceArray; |
44 | 44 | } |
45 | 45 | //Delete category & associations |
46 | -function deleteCategory($catId=0) { |
|
46 | +function deleteCategory($catId = 0){ |
|
47 | 47 | global $modx; |
48 | 48 | if ($catId) { |
49 | 49 | $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules'); |
@@ -3,18 +3,22 @@ discard block |
||
3 | 3 | //Kyle Jaebker - 08/07/06 |
4 | 4 | |
5 | 5 | //Create a new category |
6 | -function newCategory($newCat) { |
|
6 | +function newCategory($newCat) |
|
7 | +{ |
|
7 | 8 | global $modx; |
8 | 9 | $useTable = $modx->getFullTableName('categories'); |
9 | 10 | $categoryId = $modx->db->insert( |
10 | 11 | array( |
11 | 12 | 'category' => $modx->db->escape($newCat), |
12 | 13 | ), $useTable); |
13 | - if (!$categoryId) $categoryId = 0; |
|
14 | + if (!$categoryId) { |
|
15 | + $categoryId = 0; |
|
16 | + } |
|
14 | 17 | return $categoryId; |
15 | 18 | } |
16 | 19 | //check if new category already exists |
17 | -function checkCategory($newCat = '') { |
|
20 | +function checkCategory($newCat = '') |
|
21 | +{ |
|
18 | 22 | global $modx; |
19 | 23 | $useTable = $modx->getFullTableName('categories'); |
20 | 24 | $newCat = $modx->db->escape($newCat); |
@@ -25,13 +29,17 @@ discard block |
||
25 | 29 | return 0; |
26 | 30 | } |
27 | 31 | //Check for category, create new if not exists |
28 | -function getCategory($category='') { |
|
32 | +function getCategory($category='') |
|
33 | +{ |
|
29 | 34 | $categoryId = checkCategory($category); |
30 | - if(!$categoryId) $categoryId = newCategory($category); |
|
35 | + if(!$categoryId) { |
|
36 | + $categoryId = newCategory($category); |
|
37 | + } |
|
31 | 38 | return $categoryId; |
32 | 39 | } |
33 | 40 | //Get all categories |
34 | -function getCategories() { |
|
41 | +function getCategories() |
|
42 | +{ |
|
35 | 43 | global $modx; |
36 | 44 | $useTable = $modx->getFullTableName('categories'); |
37 | 45 | $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category'); |
@@ -43,7 +51,8 @@ discard block |
||
43 | 51 | return $resourceArray; |
44 | 52 | } |
45 | 53 | //Delete category & associations |
46 | -function deleteCategory($catId=0) { |
|
54 | +function deleteCategory($catId=0) |
|
55 | +{ |
|
47 | 56 | global $modx; |
48 | 57 | if ($catId) { |
49 | 58 | $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules'); |
@@ -52,6 +52,9 @@ discard block |
||
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 |
||
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; |
@@ -12,280 +12,280 @@ |
||
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 . " </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 . " </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 = '•'; |
|
272 | - } else { |
|
273 | - $value = ' '; |
|
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 . " </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 . " </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 = '•'; |
|
272 | + } else { |
|
273 | + $value = ' '; |
|
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 | } |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid{ |
|
14 | 14 | |
15 | 15 | var $ds; // datasource |
16 | 16 | var $id; |
17 | - var $pageSize; // pager settings |
|
17 | + var $pageSize; // pager settings |
|
18 | 18 | var $pageNumber; |
19 | 19 | var $pager; |
20 | - var $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
20 | + var $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | 21 | |
22 | 22 | var $cssStyle; |
23 | 23 | var $cssClass; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | var $colAligns; |
36 | 36 | var $colWraps; |
37 | 37 | var $colColors; |
38 | - var $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
38 | + var $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | 39 | // data type: integer,float,currency,date |
40 | 40 | |
41 | 41 | var $header; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | var $cellPadding; |
44 | 44 | var $cellSpacing; |
45 | 45 | |
46 | - var $rowAlign; // vertical alignment: top, middle, bottom |
|
46 | + var $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | 47 | var $rowIdField; |
48 | 48 | |
49 | 49 | var $pagerStyle; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | var $selPageClass; |
53 | 53 | var $noRecordMsg = "No records found."; |
54 | 54 | |
55 | - function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
55 | + function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
56 | 56 | global $__DataGridCnt; |
57 | 57 | |
58 | 58 | // set id |
59 | 59 | $__DataGridCnt++; |
60 | - $this->id = $this->id ? $id : "dg" . $__DataGridCnt; |
|
60 | + $this->id = $this->id ? $id : "dg".$__DataGridCnt; |
|
61 | 61 | |
62 | 62 | // set datasource |
63 | 63 | $this->ds = $ds; |
@@ -68,50 +68,50 @@ discard block |
||
68 | 68 | $this->pagerLocation = 'top-right'; |
69 | 69 | } |
70 | 70 | |
71 | - function setDataSource($ds) { |
|
71 | + function setDataSource($ds){ |
|
72 | 72 | $this->ds = $ds; |
73 | 73 | } |
74 | 74 | |
75 | - function render() { |
|
75 | + function render(){ |
|
76 | 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 . "'" : ''; |
|
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 | 81 | |
82 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
83 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
82 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
83 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
84 | 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 . "'" : ''; |
|
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 | 89 | |
90 | 90 | $this->_alt = 0; |
91 | 91 | $this->_total = 0; |
92 | 92 | |
93 | 93 | $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
94 | 94 | |
95 | - if(!$cssStyle && !$cssClass) { |
|
95 | + if (!$cssStyle && !$cssClass) { |
|
96 | 96 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
97 | 97 | } |
98 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
98 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
99 | 99 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
100 | 100 | } |
101 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
101 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
102 | 102 | $this->_itemStyle = "style='color:black;'"; |
103 | 103 | } |
104 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
104 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
105 | 105 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
106 | 106 | } |
107 | 107 | |
108 | - if($this->_isDataset && !$this->columns) { |
|
108 | + if ($this->_isDataset && !$this->columns) { |
|
109 | 109 | $cols = $modx->db->numFields($this->ds); |
110 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
110 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // start grid |
114 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
114 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
115 | 115 | $tblEnd = "</table>"; |
116 | 116 | |
117 | 117 | // build column header |
@@ -122,33 +122,33 @@ discard block |
||
122 | 122 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
123 | 123 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
124 | 124 | $this->_colcount = count($this->_colnames); |
125 | - if(!$this->_isDataset) { |
|
125 | + if (!$this->_isDataset) { |
|
126 | 126 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
127 | 127 | $this->ds = array_chunk($this->ds, $this->_colcount); |
128 | 128 | } |
129 | 129 | $tblColHdr = "<thead><tr>"; |
130 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
130 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
131 | 131 | $name = $this->_colnames[$c]; |
132 | 132 | $width = $this->_colwidths[$c]; |
133 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
133 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
134 | 134 | } |
135 | 135 | $tblColHdr .= "</tr></thead>\n"; |
136 | 136 | |
137 | 137 | // build rows |
138 | 138 | $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
139 | 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"; |
|
140 | + if ($rowcount == 0) { |
|
141 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
142 | 142 | } else { |
143 | 143 | // render grid items |
144 | - if($this->pageSize <= 0) { |
|
145 | - for($r = 0; $r < $rowcount; $r++) { |
|
144 | + if ($this->pageSize <= 0) { |
|
145 | + for ($r = 0; $r < $rowcount; $r++) { |
|
146 | 146 | $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
147 | 147 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
148 | 148 | } |
149 | 149 | } else { |
150 | - if(!$this->pager) { |
|
151 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
150 | + if (!$this->pager) { |
|
151 | + include_once dirname(__FILE__)."/datasetpager.class.php"; |
|
152 | 152 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
153 | 153 | $this->pager->setRenderRowFnc($this); // pass this object |
154 | 154 | $this->pager->cssStyle = $pagerStyle; |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | $o = $tblStart; |
169 | 169 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
170 | 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>"; |
|
171 | + if ($this->header) { |
|
172 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
173 | 173 | } |
174 | - if($tblPager && $ptop) { |
|
175 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
174 | + if ($tblPager && $ptop) { |
|
175 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
176 | 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 . " </td></tr>"; |
|
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." </td></tr>"; |
|
180 | 180 | } |
181 | - if($this->footer) { |
|
182 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
181 | + if ($this->footer) { |
|
182 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
183 | 183 | } |
184 | 184 | $o .= $tblEnd; |
185 | 185 | return $o; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | |
188 | 188 | // format column values |
189 | 189 | |
190 | - function RenderRowFnc($n, $row) { |
|
191 | - if($this->_alt == 0) { |
|
190 | + function RenderRowFnc($n, $row){ |
|
191 | + if ($this->_alt == 0) { |
|
192 | 192 | $Style = $this->_itemStyle; |
193 | 193 | $Class = $this->_itemClass; |
194 | 194 | $this->_alt = 1; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $this->_alt = 0; |
199 | 199 | } |
200 | 200 | $o = "<tr>"; |
201 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
201 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
202 | 202 | $colStyle = $Style; |
203 | 203 | $fld = trim($this->_fieldnames[$c]); |
204 | 204 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -207,67 +207,67 @@ discard block |
||
207 | 207 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
208 | 208 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
209 | 209 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
210 | - if($color && $Style) { |
|
211 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
210 | + if ($color && $Style) { |
|
211 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
212 | 212 | } |
213 | 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>"; |
|
214 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
215 | 215 | } |
216 | 216 | $o .= "</tr>\n"; |
217 | 217 | return $o; |
218 | 218 | } |
219 | 219 | |
220 | - function formatColumnValue($row, $value, $type, &$align) { |
|
221 | - if(strpos($type, ":") !== false) { |
|
220 | + function formatColumnValue($row, $value, $type, &$align){ |
|
221 | + if (strpos($type, ":") !== false) { |
|
222 | 222 | list($type, $type_format) = explode(":", $type, 2); |
223 | 223 | } |
224 | - switch(strtolower($type)) { |
|
224 | + switch (strtolower($type)) { |
|
225 | 225 | case "integer": |
226 | - if($align == "") { |
|
226 | + if ($align == "") { |
|
227 | 227 | $align = "right"; |
228 | 228 | } |
229 | 229 | $value = number_format($value); |
230 | 230 | break; |
231 | 231 | |
232 | 232 | case "float": |
233 | - if($align == "") { |
|
233 | + if ($align == "") { |
|
234 | 234 | $align = "right"; |
235 | 235 | } |
236 | - if(!$type_format) { |
|
236 | + if (!$type_format) { |
|
237 | 237 | $type_format = 2; |
238 | 238 | } |
239 | 239 | $value = number_format($value, $type_format); |
240 | 240 | break; |
241 | 241 | |
242 | 242 | case "currency": |
243 | - if($align == "") { |
|
243 | + if ($align == "") { |
|
244 | 244 | $align = "right"; |
245 | 245 | } |
246 | - if(!$type_format) { |
|
246 | + if (!$type_format) { |
|
247 | 247 | $type_format = 2; |
248 | 248 | } |
249 | - $value = "$" . number_format($value, $type_format); |
|
249 | + $value = "$".number_format($value, $type_format); |
|
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "date": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!is_numeric($value)) { |
|
256 | + if (!is_numeric($value)) { |
|
257 | 257 | $value = strtotime($value); |
258 | 258 | } |
259 | - if(!$type_format) { |
|
259 | + if (!$type_format) { |
|
260 | 260 | $type_format = "%A %d, %B %Y"; |
261 | 261 | } |
262 | 262 | $value = strftime($type_format, $value); |
263 | 263 | break; |
264 | 264 | |
265 | 265 | case "boolean": |
266 | - if($align == '') { |
|
266 | + if ($align == '') { |
|
267 | 267 | $align = "center"; |
268 | 268 | } |
269 | 269 | $value = number_format($value); |
270 | - if($value) { |
|
270 | + if ($value) { |
|
271 | 271 | $value = '•'; |
272 | 272 | } else { |
273 | 273 | $value = ' '; |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | // replace [+value+] first |
279 | 279 | $value = str_replace("[+value+]", $value, $type_format); |
280 | 280 | // replace other [+fields+] |
281 | - if(strpos($value, "[+") !== false) { |
|
282 | - foreach($row as $k => $v) { |
|
281 | + if (strpos($value, "[+") !== false) { |
|
282 | + foreach ($row as $k => $v) { |
|
283 | 283 | $value = str_replace("[+$k+]", $v, $value); |
284 | 284 | } |
285 | 285 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataGridCnt = 0; |
12 | 12 | |
13 | -class DataGrid { |
|
13 | +class DataGrid |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | var $ds; // datasource |
16 | 17 | var $id; |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | var $selPageClass; |
53 | 54 | var $noRecordMsg = "No records found."; |
54 | 55 | |
55 | - function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
56 | + function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
57 | + { |
|
56 | 58 | global $__DataGridCnt; |
57 | 59 | |
58 | 60 | // set id |
@@ -68,11 +70,13 @@ discard block |
||
68 | 70 | $this->pagerLocation = 'top-right'; |
69 | 71 | } |
70 | 72 | |
71 | - function setDataSource($ds) { |
|
73 | + function setDataSource($ds) |
|
74 | + { |
|
72 | 75 | $this->ds = $ds; |
73 | 76 | } |
74 | 77 | |
75 | - function render() { |
|
78 | + function render() |
|
79 | + { |
|
76 | 80 | global $modx; |
77 | 81 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
78 | 82 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | |
108 | 112 | if($this->_isDataset && !$this->columns) { |
109 | 113 | $cols = $modx->db->numFields($this->ds); |
110 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
114 | + for($i = 0; $i < $cols; $i++) { |
|
115 | + $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
116 | + } |
|
111 | 117 | } |
112 | 118 | |
113 | 119 | // start grid |
@@ -187,7 +193,8 @@ discard block |
||
187 | 193 | |
188 | 194 | // format column values |
189 | 195 | |
190 | - function RenderRowFnc($n, $row) { |
|
196 | + function RenderRowFnc($n, $row) |
|
197 | + { |
|
191 | 198 | if($this->_alt == 0) { |
192 | 199 | $Style = $this->_itemStyle; |
193 | 200 | $Class = $this->_itemClass; |
@@ -217,7 +224,8 @@ discard block |
||
217 | 224 | return $o; |
218 | 225 | } |
219 | 226 | |
220 | - function formatColumnValue($row, $value, $type, &$align) { |
|
227 | + function formatColumnValue($row, $value, $type, &$align) |
|
228 | + { |
|
221 | 229 | if(strpos($type, ":") !== false) { |
222 | 230 | list($type, $type_format) = explode(":", $type, 2); |
223 | 231 | } |
@@ -73,6 +73,9 @@ |
||
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 |
@@ -12,181 +12,181 @@ |
||
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 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager{ |
|
14 | 14 | |
15 | 15 | var $ds; // datasource |
16 | 16 | var $pageSize; |
@@ -27,26 +27,26 @@ discard block |
||
27 | 27 | var $selPageStyle; |
28 | 28 | var $selPageClass; |
29 | 29 | |
30 | - function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
30 | + function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
31 | 31 | global $_PAGE; // use view state object |
32 | 32 | |
33 | 33 | global $__DataSetPagerCnt; |
34 | 34 | |
35 | 35 | // set id |
36 | 36 | $__DataSetPagerCnt++; |
37 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
37 | + $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt; |
|
38 | 38 | |
39 | 39 | // get pagenumber |
40 | 40 | // by setting pager to -1 cause pager to load it's last page number |
41 | - if($pageNumber == -1) { |
|
41 | + if ($pageNumber == -1) { |
|
42 | 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']; |
|
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 | 47 | } |
48 | 48 | } |
49 | - if(!is_numeric($pageNumber)) { |
|
49 | + if (!is_numeric($pageNumber)) { |
|
50 | 50 | $pageNumber = 1; |
51 | 51 | } |
52 | 52 | |
@@ -57,40 +57,40 @@ discard block |
||
57 | 57 | $this->pager = ''; |
58 | 58 | } |
59 | 59 | |
60 | - function getRenderedPager() { |
|
60 | + function getRenderedPager(){ |
|
61 | 61 | return $this->pager; |
62 | 62 | } |
63 | 63 | |
64 | - function getRenderedRows() { |
|
64 | + function getRenderedRows(){ |
|
65 | 65 | return $this->rows; |
66 | 66 | } |
67 | 67 | |
68 | - function setDataSource($ds) { |
|
68 | + function setDataSource($ds){ |
|
69 | 69 | $this->ds = $ds; |
70 | 70 | } |
71 | 71 | |
72 | - function setPageSize($ps) { |
|
72 | + function setPageSize($ps){ |
|
73 | 73 | $this->pageSize = $ps; |
74 | 74 | } |
75 | 75 | |
76 | - function setRenderRowFnc($fncName, $args = "") { |
|
76 | + function setRenderRowFnc($fncName, $args = ""){ |
|
77 | 77 | $this->renderRowFnc = &$fncName; |
78 | - $this->renderRowFncArgs = $args; // extra agruments |
|
78 | + $this->renderRowFncArgs = $args; // extra agruments |
|
79 | 79 | |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | - function setRenderPagerFnc($fncName, $args = "") { |
|
83 | + function setRenderPagerFnc($fncName, $args = ""){ |
|
84 | 84 | $this->renderPagerFnc = $fncName; |
85 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
85 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
86 | 86 | } |
87 | 87 | |
88 | - function render() { |
|
88 | + function render(){ |
|
89 | 89 | global $modx, $_PAGE; |
90 | 90 | |
91 | 91 | $isDataset = $modx->db->isResult($this->ds); |
92 | 92 | |
93 | - if(!$this->selPageStyle) { |
|
93 | + if (!$this->selPageStyle) { |
|
94 | 94 | $this->selPageStyle = "font-weight:bold"; |
95 | 95 | } |
96 | 96 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
99 | 99 | |
100 | 100 | // render: no records found |
101 | - if($tnr <= 0) { |
|
101 | + if ($tnr <= 0) { |
|
102 | 102 | $fnc = $this->renderRowFnc; |
103 | 103 | $args = $this->renderRowFncArgs; |
104 | - if(isset($fnc)) { |
|
105 | - if($args != "") { |
|
104 | + if (isset($fnc)) { |
|
105 | + if ($args != "") { |
|
106 | 106 | $this->rows .= $fnc(0, null, $args); |
107 | 107 | } // if agrs was specified then we will pass three params |
108 | 108 | else { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | // get total pages |
116 | 116 | $tp = ceil($tnr / $this->pageSize); |
117 | - if($this->pageNumber > $tp) { |
|
117 | + if ($this->pageNumber > $tp) { |
|
118 | 118 | $this->pageNumber = 1; |
119 | 119 | } |
120 | 120 | |
@@ -122,38 +122,38 @@ discard block |
||
122 | 122 | $p = $this->pageNumber; |
123 | 123 | |
124 | 124 | // save page number to view state if available |
125 | - if(isset($_PAGE['vs'])) { |
|
126 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
125 | + if (isset($_PAGE['vs'])) { |
|
126 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
130 | - if($tp > 1) { |
|
130 | + if ($tp > 1) { |
|
131 | 131 | $fnc = $this->renderPagerFnc; |
132 | 132 | $args = $this->renderPagerFncArgs; |
133 | - if(!isset($fnc)) { |
|
134 | - if($modx->isFrontend()) { |
|
135 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
133 | + if (!isset($fnc)) { |
|
134 | + if ($modx->isFrontend()) { |
|
135 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
136 | 136 | } else { |
137 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
137 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
138 | 138 | } |
139 | 139 | $i = 0; |
140 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
140 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
141 | 141 | $i++; |
142 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
142 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
143 | 143 | } |
144 | - if($i >= 1) { |
|
144 | + if ($i >= 1) { |
|
145 | 145 | $url .= "&"; |
146 | 146 | } |
147 | 147 | } |
148 | - for($i = 1; $i <= $tp; $i++) { |
|
149 | - if(isset($fnc)) { |
|
150 | - if($args != "") { |
|
148 | + for ($i = 1; $i <= $tp; $i++) { |
|
149 | + if (isset($fnc)) { |
|
150 | + if ($args != "") { |
|
151 | 151 | $this->pager .= $fnc($p, $i, $args); |
152 | 152 | } else { |
153 | 153 | $this->pager .= $fnc($p, $i); |
154 | 154 | } |
155 | 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> "; |
|
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 | 157 | } |
158 | 158 | } |
159 | 159 | } |
@@ -162,21 +162,21 @@ discard block |
||
162 | 162 | $fnc = $this->renderRowFnc; |
163 | 163 | $args = $this->renderRowFncArgs; |
164 | 164 | |
165 | - if(isset($fnc)) { |
|
165 | + if (isset($fnc)) { |
|
166 | 166 | $i = 1; |
167 | 167 | $fncObject = is_object($fnc); |
168 | 168 | $minitems = (($p - 1) * $this->pageSize) + 1; |
169 | 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 != "") { |
|
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 | 174 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
175 | 175 | } else { |
176 | 176 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
177 | 177 | } |
178 | 178 | } else { |
179 | - if($args != "") { |
|
179 | + if ($args != "") { |
|
180 | 180 | $this->rows .= $fnc($i, $row, $args); |
181 | 181 | } // if agrs was specified then we wil pass three params |
182 | 182 | else { |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | $__DataSetPagerCnt = 0; |
12 | 12 | |
13 | -class DataSetPager { |
|
13 | +class DataSetPager |
|
14 | +{ |
|
14 | 15 | |
15 | 16 | var $ds; // datasource |
16 | 17 | var $pageSize; |
@@ -27,7 +28,8 @@ discard block |
||
27 | 28 | var $selPageStyle; |
28 | 29 | var $selPageClass; |
29 | 30 | |
30 | - function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
31 | + function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
32 | + { |
|
31 | 33 | global $_PAGE; // use view state object |
32 | 34 | |
33 | 35 | global $__DataSetPagerCnt; |
@@ -57,35 +59,42 @@ discard block |
||
57 | 59 | $this->pager = ''; |
58 | 60 | } |
59 | 61 | |
60 | - function getRenderedPager() { |
|
62 | + function getRenderedPager() |
|
63 | + { |
|
61 | 64 | return $this->pager; |
62 | 65 | } |
63 | 66 | |
64 | - function getRenderedRows() { |
|
67 | + function getRenderedRows() |
|
68 | + { |
|
65 | 69 | return $this->rows; |
66 | 70 | } |
67 | 71 | |
68 | - function setDataSource($ds) { |
|
72 | + function setDataSource($ds) |
|
73 | + { |
|
69 | 74 | $this->ds = $ds; |
70 | 75 | } |
71 | 76 | |
72 | - function setPageSize($ps) { |
|
77 | + function setPageSize($ps) |
|
78 | + { |
|
73 | 79 | $this->pageSize = $ps; |
74 | 80 | } |
75 | 81 | |
76 | - function setRenderRowFnc($fncName, $args = "") { |
|
82 | + function setRenderRowFnc($fncName, $args = "") |
|
83 | + { |
|
77 | 84 | $this->renderRowFnc = &$fncName; |
78 | 85 | $this->renderRowFncArgs = $args; // extra agruments |
79 | 86 | |
80 | 87 | |
81 | 88 | } |
82 | 89 | |
83 | - function setRenderPagerFnc($fncName, $args = "") { |
|
90 | + function setRenderPagerFnc($fncName, $args = "") |
|
91 | + { |
|
84 | 92 | $this->renderPagerFnc = $fncName; |
85 | 93 | $this->renderPagerFncArgs = $args; // extra agruments |
86 | 94 | } |
87 | 95 | |
88 | - function render() { |
|
96 | + function render() |
|
97 | + { |
|
89 | 98 | global $modx, $_PAGE; |
90 | 99 | |
91 | 100 | $isDataset = $modx->db->isResult($this->ds); |
@@ -137,8 +146,10 @@ discard block |
||
137 | 146 | $url = $_SERVER['PHP_SELF'] . '?'; |
138 | 147 | } |
139 | 148 | $i = 0; |
140 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
149 | + foreach($_GET as $n => $v) { |
|
150 | + if($n != 'dpgn' . $this->id) { |
|
141 | 151 | $i++; |
152 | + } |
|
142 | 153 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
143 | 154 | } |
144 | 155 | if($i >= 1) { |
@@ -3968,7 +3968,7 @@ |
||
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 | { |
@@ -1076,10 +1076,10 @@ discard block |
||
1076 | 1076 | $list = imap_rfc822_parse_adrlist($addrstr, ''); |
1077 | 1077 | foreach ($list as $address) { |
1078 | 1078 | if ('.SYNTAX-ERROR.' != $address->host) { |
1079 | - if (static::validateAddress($address->mailbox . '@' . $address->host)) { |
|
1079 | + if (static::validateAddress($address->mailbox.'@'.$address->host)) { |
|
1080 | 1080 | $addresses[] = [ |
1081 | 1081 | 'name' => (property_exists($address, 'personal') ? $address->personal : ''), |
1082 | - 'address' => $address->mailbox . '@' . $address->host, |
|
1082 | + 'address' => $address->mailbox.'@'.$address->host, |
|
1083 | 1083 | ]; |
1084 | 1084 | } |
1085 | 1085 | } |
@@ -1225,14 +1225,14 @@ discard block |
||
1225 | 1225 | * Feel free to use and redistribute this code. But please keep this copyright notice. |
1226 | 1226 | */ |
1227 | 1227 | return (bool) preg_match( |
1228 | - '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . |
|
1229 | - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . |
|
1230 | - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . |
|
1231 | - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . |
|
1232 | - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . |
|
1233 | - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . |
|
1234 | - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . |
|
1235 | - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . |
|
1228 | + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)'. |
|
1229 | + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'. |
|
1230 | + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'. |
|
1231 | + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'. |
|
1232 | + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'. |
|
1233 | + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'. |
|
1234 | + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'. |
|
1235 | + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'. |
|
1236 | 1236 | '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', |
1237 | 1237 | $address |
1238 | 1238 | ); |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | * @see http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) |
1244 | 1244 | */ |
1245 | 1245 | return (bool) preg_match( |
1246 | - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . |
|
1246 | + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'. |
|
1247 | 1247 | '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', |
1248 | 1248 | $address |
1249 | 1249 | ); |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $errorcode = 0; |
1295 | 1295 | $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); |
1296 | 1296 | if (false !== $punycode) { |
1297 | - return substr($address, 0, $pos) . $punycode; |
|
1297 | + return substr($address, 0, $pos).$punycode; |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | } |
@@ -1358,8 +1358,8 @@ discard block |
||
1358 | 1358 | and version_compare(PHP_VERSION, '7.1.3', '<'))) |
1359 | 1359 | ) { |
1360 | 1360 | trigger_error( |
1361 | - 'Your version of PHP is affected by a bug that may result in corrupted messages.' . |
|
1362 | - ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . |
|
1361 | + 'Your version of PHP is affected by a bug that may result in corrupted messages.'. |
|
1362 | + ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in'. |
|
1363 | 1363 | ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', |
1364 | 1364 | E_USER_WARNING |
1365 | 1365 | ); |
@@ -1443,12 +1443,12 @@ discard block |
||
1443 | 1443 | ) |
1444 | 1444 | ) { |
1445 | 1445 | $header_dkim = $this->DKIM_Add( |
1446 | - $this->MIMEHeader . $this->mailHeader, |
|
1446 | + $this->MIMEHeader.$this->mailHeader, |
|
1447 | 1447 | $this->encodeHeader($this->secureHeader($this->Subject)), |
1448 | 1448 | $this->MIMEBody |
1449 | 1449 | ); |
1450 | - $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . static::$LE . |
|
1451 | - static::normalizeBreaks($header_dkim) . static::$LE; |
|
1450 | + $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ").static::$LE. |
|
1451 | + static::normalizeBreaks($header_dkim).static::$LE; |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | return true; |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | case 'mail': |
1483 | 1483 | return $this->mailSend($this->MIMEHeader, $this->MIMEBody); |
1484 | 1484 | default: |
1485 | - $sendMethod = $this->Mailer . 'Send'; |
|
1485 | + $sendMethod = $this->Mailer.'Send'; |
|
1486 | 1486 | if (method_exists($this, $sendMethod)) { |
1487 | 1487 | return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); |
1488 | 1488 | } |
@@ -1535,9 +1535,9 @@ discard block |
||
1535 | 1535 | foreach ($this->SingleToArray as $toAddr) { |
1536 | 1536 | $mail = @popen($sendmail, 'w'); |
1537 | 1537 | if (!$mail) { |
1538 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1538 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1539 | 1539 | } |
1540 | - fwrite($mail, 'To: ' . $toAddr . "\n"); |
|
1540 | + fwrite($mail, 'To: '.$toAddr."\n"); |
|
1541 | 1541 | fwrite($mail, $header); |
1542 | 1542 | fwrite($mail, $body); |
1543 | 1543 | $result = pclose($mail); |
@@ -1552,13 +1552,13 @@ discard block |
||
1552 | 1552 | [] |
1553 | 1553 | ); |
1554 | 1554 | if (0 !== $result) { |
1555 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1555 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1556 | 1556 | } |
1557 | 1557 | } |
1558 | 1558 | } else { |
1559 | 1559 | $mail = @popen($sendmail, 'w'); |
1560 | 1560 | if (!$mail) { |
1561 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1561 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1562 | 1562 | } |
1563 | 1563 | fwrite($mail, $header); |
1564 | 1564 | fwrite($mail, $body); |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | [] |
1575 | 1575 | ); |
1576 | 1576 | if (0 !== $result) { |
1577 | - throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
1577 | + throw new Exception($this->lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
1578 | 1578 | } |
1579 | 1579 | } |
1580 | 1580 | |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | $smtp_from = $this->Sender; |
1733 | 1733 | } |
1734 | 1734 | if (!$this->smtp->mail($smtp_from)) { |
1735 | - $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); |
|
1735 | + $this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',', $this->smtp->getError())); |
|
1736 | 1736 | throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); |
1737 | 1737 | } |
1738 | 1738 | |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | } |
1754 | 1754 | |
1755 | 1755 | // Only send the DATA command if we have viable recipients |
1756 | - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { |
|
1756 | + if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header.$body)) { |
|
1757 | 1757 | throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); |
1758 | 1758 | } |
1759 | 1759 | |
@@ -1783,10 +1783,10 @@ discard block |
||
1783 | 1783 | if (count($bad_rcpt) > 0) { |
1784 | 1784 | $errstr = ''; |
1785 | 1785 | foreach ($bad_rcpt as $bad) { |
1786 | - $errstr .= $bad['to'] . ': ' . $bad['error']; |
|
1786 | + $errstr .= $bad['to'].': '.$bad['error']; |
|
1787 | 1787 | } |
1788 | 1788 | throw new Exception( |
1789 | - $this->lang('recipients_failed') . $errstr, |
|
1789 | + $this->lang('recipients_failed').$errstr, |
|
1790 | 1790 | self::STOP_CONTINUE |
1791 | 1791 | ); |
1792 | 1792 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | trim($hostentry), |
1837 | 1837 | $hostinfo |
1838 | 1838 | )) { |
1839 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
1839 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
1840 | 1840 | // Not a valid host entry |
1841 | 1841 | continue; |
1842 | 1842 | } |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | |
1849 | 1849 | //Check the host name is a valid name or IP address before trying to use it |
1850 | 1850 | if (!static::isValidHost($hostinfo[3])) { |
1851 | - static::edebug($this->lang('connect_host') . ' ' . $hostentry); |
|
1851 | + static::edebug($this->lang('connect_host').' '.$hostentry); |
|
1852 | 1852 | continue; |
1853 | 1853 | } |
1854 | 1854 | $prefix = ''; |
@@ -1868,7 +1868,7 @@ discard block |
||
1868 | 1868 | if ('tls' === $secure or 'ssl' === $secure) { |
1869 | 1869 | //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled |
1870 | 1870 | if (!$sslext) { |
1871 | - throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); |
|
1871 | + throw new Exception($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | $host = $hostinfo[3]; |
@@ -1877,7 +1877,7 @@ discard block |
||
1877 | 1877 | if ($tport > 0 and $tport < 65536) { |
1878 | 1878 | $port = $tport; |
1879 | 1879 | } |
1880 | - if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { |
|
1880 | + if ($this->smtp->connect($prefix.$host, $port, $this->Timeout, $options)) { |
|
1881 | 1881 | try { |
1882 | 1882 | if ($this->Helo) { |
1883 | 1883 | $hello = $this->Helo; |
@@ -1994,14 +1994,14 @@ discard block |
||
1994 | 1994 | ]; |
1995 | 1995 | if (empty($lang_path)) { |
1996 | 1996 | // Calculate an absolute path so it can work if CWD is not here |
1997 | - $lang_path = __DIR__ . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; |
|
1997 | + $lang_path = __DIR__.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR; |
|
1998 | 1998 | } |
1999 | 1999 | //Validate $langcode |
2000 | 2000 | if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { |
2001 | 2001 | $langcode = 'en'; |
2002 | 2002 | } |
2003 | 2003 | $foundlang = true; |
2004 | - $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; |
|
2004 | + $lang_file = $lang_path.'phpmailer.lang-'.$langcode.'.php'; |
|
2005 | 2005 | // There is no English translation file |
2006 | 2006 | if ('en' != $langcode) { |
2007 | 2007 | // Make sure language file path is readable |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | $addresses[] = $this->addrFormat($address); |
2047 | 2047 | } |
2048 | 2048 | |
2049 | - return $type . ': ' . implode(', ', $addresses) . static::$LE; |
|
2049 | + return $type.': '.implode(', ', $addresses).static::$LE; |
|
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | /** |
@@ -2063,9 +2063,9 @@ discard block |
||
2063 | 2063 | return $this->secureHeader($addr[0]); |
2064 | 2064 | } |
2065 | 2065 | |
2066 | - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( |
|
2066 | + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase').' <'.$this->secureHeader( |
|
2067 | 2067 | $addr[0] |
2068 | - ) . '>'; |
|
2068 | + ).'>'; |
|
2069 | 2069 | } |
2070 | 2070 | |
2071 | 2071 | /** |
@@ -2122,10 +2122,10 @@ discard block |
||
2122 | 2122 | } |
2123 | 2123 | $part = substr($word, 0, $len); |
2124 | 2124 | $word = substr($word, $len); |
2125 | - $buf .= ' ' . $part; |
|
2126 | - $message .= $buf . sprintf('=%s', static::$LE); |
|
2125 | + $buf .= ' '.$part; |
|
2126 | + $message .= $buf.sprintf('=%s', static::$LE); |
|
2127 | 2127 | } else { |
2128 | - $message .= $buf . $soft_break; |
|
2128 | + $message .= $buf.$soft_break; |
|
2129 | 2129 | } |
2130 | 2130 | $buf = ''; |
2131 | 2131 | } |
@@ -2145,7 +2145,7 @@ discard block |
||
2145 | 2145 | $word = substr($word, $len); |
2146 | 2146 | |
2147 | 2147 | if (strlen($word) > 0) { |
2148 | - $message .= $part . sprintf('=%s', static::$LE); |
|
2148 | + $message .= $part.sprintf('=%s', static::$LE); |
|
2149 | 2149 | } else { |
2150 | 2150 | $buf = $part; |
2151 | 2151 | } |
@@ -2158,13 +2158,13 @@ discard block |
||
2158 | 2158 | $buf .= $word; |
2159 | 2159 | |
2160 | 2160 | if (strlen($buf) > $length and '' != $buf_o) { |
2161 | - $message .= $buf_o . $soft_break; |
|
2161 | + $message .= $buf_o.$soft_break; |
|
2162 | 2162 | $buf = $word; |
2163 | 2163 | } |
2164 | 2164 | } |
2165 | 2165 | $firstword = false; |
2166 | 2166 | } |
2167 | - $message .= $buf . static::$LE; |
|
2167 | + $message .= $buf.static::$LE; |
|
2168 | 2168 | } |
2169 | 2169 | |
2170 | 2170 | return $message; |
@@ -2310,7 +2310,7 @@ discard block |
||
2310 | 2310 | if ('' == $this->XMailer) { |
2311 | 2311 | $result .= $this->headerLine( |
2312 | 2312 | 'X-Mailer', |
2313 | - 'PHPMailer ' . self::VERSION . ' (https://github.com/PHPMailer/PHPMailer)' |
|
2313 | + 'PHPMailer '.self::VERSION.' (https://github.com/PHPMailer/PHPMailer)' |
|
2314 | 2314 | ); |
2315 | 2315 | } else { |
2316 | 2316 | $myXmailer = trim($this->XMailer); |
@@ -2320,7 +2320,7 @@ discard block |
||
2320 | 2320 | } |
2321 | 2321 | |
2322 | 2322 | if ('' != $this->ConfirmReadingTo) { |
2323 | - $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); |
|
2323 | + $result .= $this->headerLine('Disposition-Notification-To', '<'.$this->ConfirmReadingTo.'>'); |
|
2324 | 2324 | } |
2325 | 2325 | |
2326 | 2326 | // Add custom headers |
@@ -2350,23 +2350,23 @@ discard block |
||
2350 | 2350 | switch ($this->message_type) { |
2351 | 2351 | case 'inline': |
2352 | 2352 | $result .= $this->headerLine('Content-Type', 'multipart/related;'); |
2353 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2353 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2354 | 2354 | break; |
2355 | 2355 | case 'attach': |
2356 | 2356 | case 'inline_attach': |
2357 | 2357 | case 'alt_attach': |
2358 | 2358 | case 'alt_inline_attach': |
2359 | 2359 | $result .= $this->headerLine('Content-Type', 'multipart/mixed;'); |
2360 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2360 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2361 | 2361 | break; |
2362 | 2362 | case 'alt': |
2363 | 2363 | case 'alt_inline': |
2364 | 2364 | $result .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2365 | - $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
2365 | + $result .= $this->textLine("\tboundary=\"".$this->boundary[1].'"'); |
|
2366 | 2366 | break; |
2367 | 2367 | default: |
2368 | 2368 | // Catches case 'plain': and case '': |
2369 | - $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); |
|
2369 | + $result .= $this->textLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); |
|
2370 | 2370 | $ismultipart = false; |
2371 | 2371 | break; |
2372 | 2372 | } |
@@ -2401,7 +2401,7 @@ discard block |
||
2401 | 2401 | */ |
2402 | 2402 | public function getSentMIMEMessage() |
2403 | 2403 | { |
2404 | - return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . static::$LE . static::$LE . $this->MIMEBody; |
|
2404 | + return rtrim($this->MIMEHeader.$this->mailHeader, "\n\r").static::$LE.static::$LE.$this->MIMEBody; |
|
2405 | 2405 | } |
2406 | 2406 | |
2407 | 2407 | /** |
@@ -2438,12 +2438,12 @@ discard block |
||
2438 | 2438 | $body = ''; |
2439 | 2439 | //Create unique IDs and preset boundaries |
2440 | 2440 | $this->uniqueid = $this->generateId(); |
2441 | - $this->boundary[1] = 'b1_' . $this->uniqueid; |
|
2442 | - $this->boundary[2] = 'b2_' . $this->uniqueid; |
|
2443 | - $this->boundary[3] = 'b3_' . $this->uniqueid; |
|
2441 | + $this->boundary[1] = 'b1_'.$this->uniqueid; |
|
2442 | + $this->boundary[2] = 'b2_'.$this->uniqueid; |
|
2443 | + $this->boundary[3] = 'b3_'.$this->uniqueid; |
|
2444 | 2444 | |
2445 | 2445 | if ($this->sign_key_file) { |
2446 | - $body .= $this->getMailMIME() . static::$LE; |
|
2446 | + $body .= $this->getMailMIME().static::$LE; |
|
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | $this->setWordWrap(); |
@@ -2476,7 +2476,7 @@ discard block |
||
2476 | 2476 | $altBodyEncoding = 'quoted-printable'; |
2477 | 2477 | } |
2478 | 2478 | //Use this as a preamble in all multipart message types |
2479 | - $mimepre = 'This is a multi-part message in MIME format.' . static::$LE; |
|
2479 | + $mimepre = 'This is a multi-part message in MIME format.'.static::$LE; |
|
2480 | 2480 | switch ($this->message_type) { |
2481 | 2481 | case 'inline': |
2482 | 2482 | $body .= $mimepre; |
@@ -2494,9 +2494,9 @@ discard block |
||
2494 | 2494 | break; |
2495 | 2495 | case 'inline_attach': |
2496 | 2496 | $body .= $mimepre; |
2497 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2497 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2498 | 2498 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2499 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2499 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2500 | 2500 | $body .= static::$LE; |
2501 | 2501 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); |
2502 | 2502 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2525,9 +2525,9 @@ discard block |
||
2525 | 2525 | $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2526 | 2526 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
2527 | 2527 | $body .= static::$LE; |
2528 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2528 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2529 | 2529 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2530 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2530 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2531 | 2531 | $body .= static::$LE; |
2532 | 2532 | $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); |
2533 | 2533 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2538,9 +2538,9 @@ discard block |
||
2538 | 2538 | break; |
2539 | 2539 | case 'alt_attach': |
2540 | 2540 | $body .= $mimepre; |
2541 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2541 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2542 | 2542 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2543 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2543 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2544 | 2544 | $body .= static::$LE; |
2545 | 2545 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2546 | 2546 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
@@ -2558,16 +2558,16 @@ discard block |
||
2558 | 2558 | break; |
2559 | 2559 | case 'alt_inline_attach': |
2560 | 2560 | $body .= $mimepre; |
2561 | - $body .= $this->textLine('--' . $this->boundary[1]); |
|
2561 | + $body .= $this->textLine('--'.$this->boundary[1]); |
|
2562 | 2562 | $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); |
2563 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); |
|
2563 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[2].'"'); |
|
2564 | 2564 | $body .= static::$LE; |
2565 | 2565 | $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); |
2566 | 2566 | $body .= $this->encodeString($this->AltBody, $altBodyEncoding); |
2567 | 2567 | $body .= static::$LE; |
2568 | - $body .= $this->textLine('--' . $this->boundary[2]); |
|
2568 | + $body .= $this->textLine('--'.$this->boundary[2]); |
|
2569 | 2569 | $body .= $this->headerLine('Content-Type', 'multipart/related;'); |
2570 | - $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"'); |
|
2570 | + $body .= $this->textLine("\tboundary=\"".$this->boundary[3].'"'); |
|
2571 | 2571 | $body .= static::$LE; |
2572 | 2572 | $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding); |
2573 | 2573 | $body .= $this->encodeString($this->Body, $bodyEncoding); |
@@ -2594,12 +2594,12 @@ discard block |
||
2594 | 2594 | } elseif ($this->sign_key_file) { |
2595 | 2595 | try { |
2596 | 2596 | if (!defined('PKCS7_TEXT')) { |
2597 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
2597 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
2598 | 2598 | } |
2599 | 2599 | // @TODO would be nice to use php://temp streams here |
2600 | 2600 | $file = tempnam(sys_get_temp_dir(), 'mail'); |
2601 | 2601 | if (false === file_put_contents($file, $body)) { |
2602 | - throw new Exception($this->lang('signing') . ' Could not write temp file'); |
|
2602 | + throw new Exception($this->lang('signing').' Could not write temp file'); |
|
2603 | 2603 | } |
2604 | 2604 | $signed = tempnam(sys_get_temp_dir(), 'signed'); |
2605 | 2605 | //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 |
@@ -2607,16 +2607,16 @@ discard block |
||
2607 | 2607 | $sign = @openssl_pkcs7_sign( |
2608 | 2608 | $file, |
2609 | 2609 | $signed, |
2610 | - 'file://' . realpath($this->sign_cert_file), |
|
2611 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
2610 | + 'file://'.realpath($this->sign_cert_file), |
|
2611 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
2612 | 2612 | [] |
2613 | 2613 | ); |
2614 | 2614 | } else { |
2615 | 2615 | $sign = @openssl_pkcs7_sign( |
2616 | 2616 | $file, |
2617 | 2617 | $signed, |
2618 | - 'file://' . realpath($this->sign_cert_file), |
|
2619 | - ['file://' . realpath($this->sign_key_file), $this->sign_key_pass], |
|
2618 | + 'file://'.realpath($this->sign_cert_file), |
|
2619 | + ['file://'.realpath($this->sign_key_file), $this->sign_key_pass], |
|
2620 | 2620 | [], |
2621 | 2621 | PKCS7_DETACHED, |
2622 | 2622 | $this->sign_extracerts_file |
@@ -2628,11 +2628,11 @@ discard block |
||
2628 | 2628 | @unlink($signed); |
2629 | 2629 | //The message returned by openssl contains both headers and body, so need to split them up |
2630 | 2630 | $parts = explode("\n\n", $body, 2); |
2631 | - $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE; |
|
2631 | + $this->MIMEHeader .= $parts[0].static::$LE.static::$LE; |
|
2632 | 2632 | $body = $parts[1]; |
2633 | 2633 | } else { |
2634 | 2634 | @unlink($signed); |
2635 | - throw new Exception($this->lang('signing') . openssl_error_string()); |
|
2635 | + throw new Exception($this->lang('signing').openssl_error_string()); |
|
2636 | 2636 | } |
2637 | 2637 | } catch (Exception $exc) { |
2638 | 2638 | $body = ''; |
@@ -2667,7 +2667,7 @@ discard block |
||
2667 | 2667 | if ('' == $encoding) { |
2668 | 2668 | $encoding = $this->Encoding; |
2669 | 2669 | } |
2670 | - $result .= $this->textLine('--' . $boundary); |
|
2670 | + $result .= $this->textLine('--'.$boundary); |
|
2671 | 2671 | $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); |
2672 | 2672 | $result .= static::$LE; |
2673 | 2673 | // RFC1341 part 5 says 7bit is assumed if not specified |
@@ -2688,7 +2688,7 @@ discard block |
||
2688 | 2688 | */ |
2689 | 2689 | protected function endBoundary($boundary) |
2690 | 2690 | { |
2691 | - return static::$LE . '--' . $boundary . '--' . static::$LE; |
|
2691 | + return static::$LE.'--'.$boundary.'--'.static::$LE; |
|
2692 | 2692 | } |
2693 | 2693 | |
2694 | 2694 | /** |
@@ -2724,7 +2724,7 @@ discard block |
||
2724 | 2724 | */ |
2725 | 2725 | public function headerLine($name, $value) |
2726 | 2726 | { |
2727 | - return $name . ': ' . $value . static::$LE; |
|
2727 | + return $name.': '.$value.static::$LE; |
|
2728 | 2728 | } |
2729 | 2729 | |
2730 | 2730 | /** |
@@ -2736,7 +2736,7 @@ discard block |
||
2736 | 2736 | */ |
2737 | 2737 | public function textLine($value) |
2738 | 2738 | { |
2739 | - return $value . static::$LE; |
|
2739 | + return $value.static::$LE; |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | /** |
@@ -2758,7 +2758,7 @@ discard block |
||
2758 | 2758 | { |
2759 | 2759 | try { |
2760 | 2760 | if (!@is_file($path)) { |
2761 | - throw new Exception($this->lang('file_access') . $path, self::STOP_CONTINUE); |
|
2761 | + throw new Exception($this->lang('file_access').$path, self::STOP_CONTINUE); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | // If a MIME type is not specified, try to work it out from the file name |
@@ -2885,7 +2885,7 @@ discard block |
||
2885 | 2885 | 'Content-Disposition: %s; filename="%s"%s', |
2886 | 2886 | $disposition, |
2887 | 2887 | $encoded_name, |
2888 | - static::$LE . static::$LE |
|
2888 | + static::$LE.static::$LE |
|
2889 | 2889 | ); |
2890 | 2890 | } else { |
2891 | 2891 | if (!empty($encoded_name)) { |
@@ -2893,13 +2893,13 @@ discard block |
||
2893 | 2893 | 'Content-Disposition: %s; filename=%s%s', |
2894 | 2894 | $disposition, |
2895 | 2895 | $encoded_name, |
2896 | - static::$LE . static::$LE |
|
2896 | + static::$LE.static::$LE |
|
2897 | 2897 | ); |
2898 | 2898 | } else { |
2899 | 2899 | $mime[] = sprintf( |
2900 | 2900 | 'Content-Disposition: %s%s', |
2901 | 2901 | $disposition, |
2902 | - static::$LE . static::$LE |
|
2902 | + static::$LE.static::$LE |
|
2903 | 2903 | ); |
2904 | 2904 | } |
2905 | 2905 | } |
@@ -2940,11 +2940,11 @@ discard block |
||
2940 | 2940 | { |
2941 | 2941 | try { |
2942 | 2942 | if (!file_exists($path)) { |
2943 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
2943 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
2944 | 2944 | } |
2945 | 2945 | $file_buffer = file_get_contents($path); |
2946 | 2946 | if (false === $file_buffer) { |
2947 | - throw new Exception($this->lang('file_open') . $path, self::STOP_CONTINUE); |
|
2947 | + throw new Exception($this->lang('file_open').$path, self::STOP_CONTINUE); |
|
2948 | 2948 | } |
2949 | 2949 | $file_buffer = $this->encodeString($file_buffer, $encoding); |
2950 | 2950 | |
@@ -2991,7 +2991,7 @@ discard block |
||
2991 | 2991 | $encoded = $this->encodeQP($str); |
2992 | 2992 | break; |
2993 | 2993 | default: |
2994 | - $this->setError($this->lang('encoding') . $encoding); |
|
2994 | + $this->setError($this->lang('encoding').$encoding); |
|
2995 | 2995 | break; |
2996 | 2996 | } |
2997 | 2997 | |
@@ -3057,7 +3057,7 @@ discard block |
||
3057 | 3057 | $maxlen -= $maxlen % 4; |
3058 | 3058 | $encoded = trim(chunk_split($encoded, $maxlen, "\n")); |
3059 | 3059 | } |
3060 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
3060 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
3061 | 3061 | } elseif ($matchcount > 0) { |
3062 | 3062 | //1 or more chars need encoding, use Q-encode |
3063 | 3063 | $encoding = 'Q'; |
@@ -3065,8 +3065,8 @@ discard block |
||
3065 | 3065 | $maxlen = static::STD_LINE_LENGTH - $lengthsub - 8 - strlen($this->CharSet); |
3066 | 3066 | $encoded = $this->encodeQ($str, $position); |
3067 | 3067 | $encoded = $this->wrapText($encoded, $maxlen, true); |
3068 | - $encoded = str_replace('=' . static::$LE, "\n", trim($encoded)); |
|
3069 | - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); |
|
3068 | + $encoded = str_replace('='.static::$LE, "\n", trim($encoded)); |
|
3069 | + $encoded = preg_replace('/^(.*)$/m', ' =?'.$this->CharSet."?$encoding?\\1?=", $encoded); |
|
3070 | 3070 | } elseif (strlen($str) > $maxlen) { |
3071 | 3071 | //No chars need encoding, but line is too long, so fold it |
3072 | 3072 | $encoded = trim($this->wrapText($str, $maxlen, false)); |
@@ -3127,7 +3127,7 @@ discard block |
||
3127 | 3127 | */ |
3128 | 3128 | public function base64EncodeWrapMB($str, $linebreak = null) |
3129 | 3129 | { |
3130 | - $start = '=?' . $this->CharSet . '?B?'; |
|
3130 | + $start = '=?'.$this->CharSet.'?B?'; |
|
3131 | 3131 | $end = '?='; |
3132 | 3132 | $encoded = ''; |
3133 | 3133 | if (null === $linebreak) { |
@@ -3150,7 +3150,7 @@ discard block |
||
3150 | 3150 | $chunk = base64_encode($chunk); |
3151 | 3151 | ++$lookBack; |
3152 | 3152 | } while (strlen($chunk) > $length); |
3153 | - $encoded .= $chunk . $linebreak; |
|
3153 | + $encoded .= $chunk.$linebreak; |
|
3154 | 3154 | } |
3155 | 3155 | |
3156 | 3156 | // Chomp the last linefeed |
@@ -3203,7 +3203,7 @@ discard block |
||
3203 | 3203 | // RFC 2047 section 5.1 |
3204 | 3204 | // Replace every high ascii, control, =, ? and _ characters |
3205 | 3205 | /** @noinspection SuspiciousAssignmentsInspection */ |
3206 | - $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; |
|
3206 | + $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern; |
|
3207 | 3207 | break; |
3208 | 3208 | } |
3209 | 3209 | $matches = []; |
@@ -3216,7 +3216,7 @@ discard block |
||
3216 | 3216 | array_unshift($matches[0], '='); |
3217 | 3217 | } |
3218 | 3218 | foreach (array_unique($matches[0]) as $char) { |
3219 | - $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); |
|
3219 | + $encoded = str_replace($char, '='.sprintf('%02X', ord($char)), $encoded); |
|
3220 | 3220 | } |
3221 | 3221 | } |
3222 | 3222 | // Replace spaces with _ (more readable than =20) |
@@ -3241,7 +3241,7 @@ discard block |
||
3241 | 3241 | $encoding = 'base64', |
3242 | 3242 | $type = '', |
3243 | 3243 | $disposition = 'attachment' |
3244 | - ) { |
|
3244 | + ){ |
|
3245 | 3245 | // If a MIME type is not specified, try to work it out from the file name |
3246 | 3246 | if ('' == $type) { |
3247 | 3247 | $type = static::filenameToType($filename); |
@@ -3281,7 +3281,7 @@ discard block |
||
3281 | 3281 | public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') |
3282 | 3282 | { |
3283 | 3283 | if (!@is_file($path)) { |
3284 | - $this->setError($this->lang('file_access') . $path); |
|
3284 | + $this->setError($this->lang('file_access').$path); |
|
3285 | 3285 | |
3286 | 3286 | return false; |
3287 | 3287 | } |
@@ -3335,7 +3335,7 @@ discard block |
||
3335 | 3335 | $encoding = 'base64', |
3336 | 3336 | $type = '', |
3337 | 3337 | $disposition = 'inline' |
3338 | - ) { |
|
3338 | + ){ |
|
3339 | 3339 | // If a MIME type is not specified, try to work it out from the name |
3340 | 3340 | if ('' == $type and !empty($name)) { |
3341 | 3341 | $type = static::filenameToType($name); |
@@ -3425,7 +3425,7 @@ discard block |
||
3425 | 3425 | { |
3426 | 3426 | $this->RecipientsQueue = array_filter( |
3427 | 3427 | $this->RecipientsQueue, |
3428 | - function ($params) use ($kind) { |
|
3428 | + function($params) use ($kind) { |
|
3429 | 3429 | return $params[0] != $kind; |
3430 | 3430 | } |
3431 | 3431 | ); |
@@ -3515,15 +3515,15 @@ discard block |
||
3515 | 3515 | if ('smtp' == $this->Mailer and null !== $this->smtp) { |
3516 | 3516 | $lasterror = $this->smtp->getError(); |
3517 | 3517 | if (!empty($lasterror['error'])) { |
3518 | - $msg .= $this->lang('smtp_error') . $lasterror['error']; |
|
3518 | + $msg .= $this->lang('smtp_error').$lasterror['error']; |
|
3519 | 3519 | if (!empty($lasterror['detail'])) { |
3520 | - $msg .= ' Detail: ' . $lasterror['detail']; |
|
3520 | + $msg .= ' Detail: '.$lasterror['detail']; |
|
3521 | 3521 | } |
3522 | 3522 | if (!empty($lasterror['smtp_code'])) { |
3523 | - $msg .= ' SMTP code: ' . $lasterror['smtp_code']; |
|
3523 | + $msg .= ' SMTP code: '.$lasterror['smtp_code']; |
|
3524 | 3524 | } |
3525 | 3525 | if (!empty($lasterror['smtp_code_ex'])) { |
3526 | - $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; |
|
3526 | + $msg .= ' Additional SMTP info: '.$lasterror['smtp_code_ex']; |
|
3527 | 3527 | } |
3528 | 3528 | } |
3529 | 3529 | } |
@@ -3596,7 +3596,7 @@ discard block |
||
3596 | 3596 | //Is it a valid IPv4 address? |
3597 | 3597 | return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); |
3598 | 3598 | } |
3599 | - if (filter_var('http://' . $host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
3599 | + if (filter_var('http://'.$host, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) { |
|
3600 | 3600 | //Is it a syntactically valid hostname? |
3601 | 3601 | return true; |
3602 | 3602 | } |
@@ -3622,7 +3622,7 @@ discard block |
||
3622 | 3622 | //Include a link to troubleshooting docs on SMTP connection failure |
3623 | 3623 | //this is by far the biggest cause of support questions |
3624 | 3624 | //but it's usually not PHPMailer's fault. |
3625 | - return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
3625 | + return $this->language[$key].' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; |
|
3626 | 3626 | } |
3627 | 3627 | |
3628 | 3628 | return $this->language[$key]; |
@@ -3710,14 +3710,14 @@ discard block |
||
3710 | 3710 | } |
3711 | 3711 | //Hash the decoded data, not the URL so that the same data-URI image used in multiple places |
3712 | 3712 | //will only be embedded once, even if it used a different encoding |
3713 | - $cid = hash('sha256', $data) . '@phpmailer.0'; // RFC2392 S 2 |
|
3713 | + $cid = hash('sha256', $data).'@phpmailer.0'; // RFC2392 S 2 |
|
3714 | 3714 | |
3715 | 3715 | if (!$this->cidExists($cid)) { |
3716 | - $this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1]); |
|
3716 | + $this->addStringEmbeddedImage($data, $cid, 'embed'.$imgindex, 'base64', $match[1]); |
|
3717 | 3717 | } |
3718 | 3718 | $message = str_replace( |
3719 | 3719 | $images[0][$imgindex], |
3720 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
3720 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
3721 | 3721 | $message |
3722 | 3722 | ); |
3723 | 3723 | continue; |
@@ -3736,7 +3736,7 @@ discard block |
||
3736 | 3736 | if ('.' == $directory) { |
3737 | 3737 | $directory = ''; |
3738 | 3738 | } |
3739 | - $cid = hash('sha256', $url) . '@phpmailer.0'; // RFC2392 S 2 |
|
3739 | + $cid = hash('sha256', $url).'@phpmailer.0'; // RFC2392 S 2 |
|
3740 | 3740 | if (strlen($basedir) > 1 and '/' != substr($basedir, -1)) { |
3741 | 3741 | $basedir .= '/'; |
3742 | 3742 | } |
@@ -3744,7 +3744,7 @@ discard block |
||
3744 | 3744 | $directory .= '/'; |
3745 | 3745 | } |
3746 | 3746 | if ($this->addEmbeddedImage( |
3747 | - $basedir . $directory . $filename, |
|
3747 | + $basedir.$directory.$filename, |
|
3748 | 3748 | $cid, |
3749 | 3749 | $filename, |
3750 | 3750 | 'base64', |
@@ -3752,8 +3752,8 @@ discard block |
||
3752 | 3752 | ) |
3753 | 3753 | ) { |
3754 | 3754 | $message = preg_replace( |
3755 | - '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', |
|
3756 | - $images[1][$imgindex] . '="cid:' . $cid . '"', |
|
3755 | + '/'.$images[1][$imgindex].'=["\']'.preg_quote($url, '/').'["\']/Ui', |
|
3756 | + $images[1][$imgindex].'="cid:'.$cid.'"', |
|
3757 | 3757 | $message |
3758 | 3758 | ); |
3759 | 3759 | } |
@@ -4027,7 +4027,7 @@ discard block |
||
4027 | 4027 | |
4028 | 4028 | return true; |
4029 | 4029 | } |
4030 | - $this->setError($this->lang('variable_set') . $name); |
|
4030 | + $this->setError($this->lang('variable_set').$name); |
|
4031 | 4031 | |
4032 | 4032 | return false; |
4033 | 4033 | } |
@@ -4121,7 +4121,7 @@ discard block |
||
4121 | 4121 | if (((0x21 <= $ord) and ($ord <= 0x3A)) or $ord == 0x3C or ((0x3E <= $ord) and ($ord <= 0x7E))) { |
4122 | 4122 | $line .= $txt[$i]; |
4123 | 4123 | } else { |
4124 | - $line .= '=' . sprintf('%02X', $ord); |
|
4124 | + $line .= '='.sprintf('%02X', $ord); |
|
4125 | 4125 | } |
4126 | 4126 | } |
4127 | 4127 | |
@@ -4141,14 +4141,13 @@ discard block |
||
4141 | 4141 | { |
4142 | 4142 | if (!defined('PKCS7_TEXT')) { |
4143 | 4143 | if ($this->exceptions) { |
4144 | - throw new Exception($this->lang('extension_missing') . 'openssl'); |
|
4144 | + throw new Exception($this->lang('extension_missing').'openssl'); |
|
4145 | 4145 | } |
4146 | 4146 | |
4147 | 4147 | return ''; |
4148 | 4148 | } |
4149 | 4149 | $privKeyStr = !empty($this->DKIM_private_string) ? |
4150 | - $this->DKIM_private_string : |
|
4151 | - file_get_contents($this->DKIM_private); |
|
4150 | + $this->DKIM_private_string : file_get_contents($this->DKIM_private); |
|
4152 | 4151 | if ('' != $this->DKIM_passphrase) { |
4153 | 4152 | $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); |
4154 | 4153 | } else { |
@@ -4200,7 +4199,7 @@ discard block |
||
4200 | 4199 | //But then says to delete space before and after the colon. |
4201 | 4200 | //Net result is the same as trimming both ends of the value. |
4202 | 4201 | //by elimination, the same applies to the field name |
4203 | - $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t"); |
|
4202 | + $lines[$key] = trim($heading, " \t").':'.trim($value, " \t"); |
|
4204 | 4203 | } |
4205 | 4204 | |
4206 | 4205 | return implode("\r\n", $lines); |
@@ -4226,7 +4225,7 @@ discard block |
||
4226 | 4225 | $body = static::normalizeBreaks($body, "\r\n"); |
4227 | 4226 | |
4228 | 4227 | //Reduce multiple trailing line breaks to a single one |
4229 | - return rtrim($body, "\r\n") . "\r\n"; |
|
4228 | + return rtrim($body, "\r\n")."\r\n"; |
|
4230 | 4229 | } |
4231 | 4230 | |
4232 | 4231 | /** |
@@ -4282,33 +4281,33 @@ discard block |
||
4282 | 4281 | if ('' == $this->DKIM_identity) { |
4283 | 4282 | $ident = ''; |
4284 | 4283 | } else { |
4285 | - $ident = ' i=' . $this->DKIM_identity . ';'; |
|
4286 | - } |
|
4287 | - $dkimhdrs = 'DKIM-Signature: v=1; a=' . |
|
4288 | - $DKIMsignatureType . '; q=' . |
|
4289 | - $DKIMquery . '; l=' . |
|
4290 | - $DKIMlen . '; s=' . |
|
4291 | - $this->DKIM_selector . |
|
4292 | - ";\r\n" . |
|
4293 | - "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . |
|
4294 | - "\th=From:To:Date:Subject;\r\n" . |
|
4295 | - "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . |
|
4296 | - "\tz=$from\r\n" . |
|
4297 | - "\t|$to\r\n" . |
|
4298 | - "\t|$date\r\n" . |
|
4299 | - "\t|$subject;\r\n" . |
|
4300 | - "\tbh=" . $DKIMb64 . ";\r\n" . |
|
4284 | + $ident = ' i='.$this->DKIM_identity.';'; |
|
4285 | + } |
|
4286 | + $dkimhdrs = 'DKIM-Signature: v=1; a='. |
|
4287 | + $DKIMsignatureType.'; q='. |
|
4288 | + $DKIMquery.'; l='. |
|
4289 | + $DKIMlen.'; s='. |
|
4290 | + $this->DKIM_selector. |
|
4291 | + ";\r\n". |
|
4292 | + "\tt=".$DKIMtime.'; c='.$DKIMcanonicalization.";\r\n". |
|
4293 | + "\th=From:To:Date:Subject;\r\n". |
|
4294 | + "\td=".$this->DKIM_domain.';'.$ident."\r\n". |
|
4295 | + "\tz=$from\r\n". |
|
4296 | + "\t|$to\r\n". |
|
4297 | + "\t|$date\r\n". |
|
4298 | + "\t|$subject;\r\n". |
|
4299 | + "\tbh=".$DKIMb64.";\r\n". |
|
4301 | 4300 | "\tb="; |
4302 | 4301 | $toSign = $this->DKIM_HeaderC( |
4303 | - $from_header . "\r\n" . |
|
4304 | - $to_header . "\r\n" . |
|
4305 | - $date_header . "\r\n" . |
|
4306 | - $subject_header . "\r\n" . |
|
4302 | + $from_header."\r\n". |
|
4303 | + $to_header."\r\n". |
|
4304 | + $date_header."\r\n". |
|
4305 | + $subject_header."\r\n". |
|
4307 | 4306 | $dkimhdrs |
4308 | 4307 | ); |
4309 | 4308 | $signed = $this->DKIM_Sign($toSign); |
4310 | 4309 | |
4311 | - return static::normalizeBreaks($dkimhdrs . $signed) . static::$LE; |
|
4310 | + return static::normalizeBreaks($dkimhdrs.$signed).static::$LE; |
|
4312 | 4311 | } |
4313 | 4312 | |
4314 | 4313 | /** |
@@ -4321,7 +4320,7 @@ discard block |
||
4321 | 4320 | */ |
4322 | 4321 | public static function hasLineLongerThanMax($str) |
4323 | 4322 | { |
4324 | - return (bool) preg_match('/^(.{' . (self::MAX_LINE_LENGTH + strlen(static::$LE)) . ',})/m', $str); |
|
4323 | + return (bool) preg_match('/^(.{'.(self::MAX_LINE_LENGTH + strlen(static::$LE)).',})/m', $str); |
|
4325 | 4324 | } |
4326 | 4325 | |
4327 | 4326 | /** |
@@ -2059,7 +2059,8 @@ discard block |
||
2059 | 2059 | */ |
2060 | 2060 | public function addrFormat($addr) |
2061 | 2061 | { |
2062 | - if (empty($addr[1])) { // No name provided |
|
2062 | + if (empty($addr[1])) { |
|
2063 | +// No name provided |
|
2063 | 2064 | return $this->secureHeader($addr[0]); |
2064 | 2065 | } |
2065 | 2066 | |
@@ -3425,7 +3426,7 @@ discard block |
||
3425 | 3426 | { |
3426 | 3427 | $this->RecipientsQueue = array_filter( |
3427 | 3428 | $this->RecipientsQueue, |
3428 | - function ($params) use ($kind) { |
|
3429 | + function ($params) use ($kind){ |
|
3429 | 3430 | return $params[0] != $kind; |
3430 | 3431 | } |
3431 | 3432 | ); |
@@ -209,7 +209,7 @@ |
||
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 |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $username = '', |
150 | 150 | $password = '', |
151 | 151 | $debug_level = 0 |
152 | - ) { |
|
152 | + ){ |
|
153 | 153 | $pop = new self(); |
154 | 154 | |
155 | 155 | return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level); |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | // Send the Username |
291 | - $this->sendString("USER $username" . static::LE); |
|
291 | + $this->sendString("USER $username".static::LE); |
|
292 | 292 | $pop3_response = $this->getResponse(); |
293 | 293 | if ($this->checkResponse($pop3_response)) { |
294 | 294 | // Send the Password |
295 | - $this->sendString("PASS $password" . static::LE); |
|
295 | + $this->sendString("PASS $password".static::LE); |
|
296 | 296 | $pop3_response = $this->getResponse(); |
297 | 297 | if ($this->checkResponse($pop3_response)) { |
298 | 298 | return true; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | protected function catchWarning($errno, $errstr, $errfile, $errline) |
413 | 413 | { |
414 | 414 | $this->setError( |
415 | - 'Connecting to the POP3 server raised a PHP warning:' . |
|
415 | + 'Connecting to the POP3 server raised a PHP warning:'. |
|
416 | 416 | "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline" |
417 | 417 | ); |
418 | 418 | } |
@@ -344,7 +344,8 @@ |
||
344 | 344 | protected function sendString($string) |
345 | 345 | { |
346 | 346 | if ($this->pop_conn) { |
347 | - if ($this->do_debug >= 2) { //Show client messages when debug >= 2 |
|
347 | + if ($this->do_debug >= 2) { |
|
348 | +//Show client messages when debug >= 2 |
|
348 | 349 | echo 'Client -> Server: ', $string; |
349 | 350 | } |
350 | 351 |
@@ -288,11 +288,11 @@ |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | // Send the Username |
291 | - $this->sendString("USER $username" . static::LE); |
|
291 | + $this->sendString("user $username" . static::LE); |
|
292 | 292 | $pop3_response = $this->getResponse(); |
293 | 293 | if ($this->checkResponse($pop3_response)) { |
294 | 294 | // Send the Password |
295 | - $this->sendString("PASS $password" . static::LE); |
|
295 | + $this->sendString("pass $password" . static::LE); |
|
296 | 296 | $pop3_response = $this->getResponse(); |
297 | 297 | if ($this->checkResponse($pop3_response)) { |
298 | 298 | return true; |
@@ -1314,7 +1314,7 @@ |
||
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 | */ |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | // Connect to the SMTP server |
309 | 309 | $this->edebug( |
310 | - "Connection: opening to $host:$port, timeout=$timeout, options=" . |
|
310 | + "Connection: opening to $host:$port, timeout=$timeout, options=". |
|
311 | 311 | (count($options) > 0 ? var_export($options, true) : 'array()'), |
312 | 312 | self::DEBUG_CONNECTION |
313 | 313 | ); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $socket_context = stream_context_create($options); |
318 | 318 | set_error_handler([$this, 'errorHandler']); |
319 | 319 | $this->smtp_conn = stream_socket_client( |
320 | - $host . ':' . $port, |
|
320 | + $host.':'.$port, |
|
321 | 321 | $errno, |
322 | 322 | $errstr, |
323 | 323 | $timeout, |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | (string) $errstr |
351 | 351 | ); |
352 | 352 | $this->edebug( |
353 | - 'SMTP ERROR: ' . $this->error['error'] |
|
353 | + 'SMTP ERROR: '.$this->error['error'] |
|
354 | 354 | . ": $errstr ($errno)", |
355 | 355 | self::DEBUG_CLIENT |
356 | 356 | ); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | // Get any announcement |
372 | 372 | $announce = $this->get_lines(); |
373 | - $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); |
|
373 | + $this->edebug('SERVER -> CLIENT: '.$announce, self::DEBUG_SERVER); |
|
374 | 374 | |
375 | 375 | return true; |
376 | 376 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $password, |
427 | 427 | $authtype = null, |
428 | 428 | $OAuth = null |
429 | - ) { |
|
429 | + ){ |
|
430 | 430 | if (!$this->server_caps) { |
431 | 431 | $this->setError('Authentication is not allowed before HELO/EHLO'); |
432 | 432 | |
@@ -443,15 +443,15 @@ discard block |
||
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | - $this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); |
|
446 | + $this->edebug('Auth method requested: '.($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); |
|
447 | 447 | $this->edebug( |
448 | - 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), |
|
448 | + 'Auth methods available on the server: '.implode(',', $this->server_caps['AUTH']), |
|
449 | 449 | self::DEBUG_LOWLEVEL |
450 | 450 | ); |
451 | 451 | |
452 | 452 | //If we have requested a specific auth type, check the server supports it before trying others |
453 | 453 | if (!in_array($authtype, $this->server_caps['AUTH'])) { |
454 | - $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL); |
|
454 | + $this->edebug('Requested auth method not available: '.$authtype, self::DEBUG_LOWLEVEL); |
|
455 | 455 | $authtype = null; |
456 | 456 | } |
457 | 457 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | return false; |
471 | 471 | } |
472 | - self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); |
|
472 | + self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | if (!in_array($authtype, $this->server_caps['AUTH'])) { |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | // Send encoded username and password |
490 | 490 | if (!$this->sendCommand( |
491 | 491 | 'User & Password', |
492 | - base64_encode("\0" . $username . "\0" . $password), |
|
492 | + base64_encode("\0".$username."\0".$password), |
|
493 | 493 | 235 |
494 | 494 | ) |
495 | 495 | ) { |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $challenge = base64_decode(substr($this->last_reply, 4)); |
518 | 518 | |
519 | 519 | // Build the response |
520 | - $response = $username . ' ' . $this->hmac($challenge, $password); |
|
520 | + $response = $username.' '.$this->hmac($challenge, $password); |
|
521 | 521 | |
522 | 522 | // send encoded credentials |
523 | 523 | return $this->sendCommand('Username', base64_encode($response), 235); |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $oauth = $OAuth->getOauth64(); |
530 | 530 | |
531 | 531 | // Start authentication |
532 | - if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) { |
|
532 | + if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 '.$oauth, 235)) { |
|
533 | 533 | return false; |
534 | 534 | } |
535 | 535 | break; |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $k_ipad = $key ^ $ipad; |
577 | 577 | $k_opad = $key ^ $opad; |
578 | 578 | |
579 | - return md5($k_opad . pack('H*', md5($k_ipad . $data))); |
|
579 | + return md5($k_opad.pack('H*', md5($k_ipad.$data))); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | } |
692 | 692 | //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 |
693 | 693 | if ($in_headers) { |
694 | - $line = "\t" . $line; |
|
694 | + $line = "\t".$line; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | $lines_out[] = $line; |
@@ -700,9 +700,9 @@ discard block |
||
700 | 700 | foreach ($lines_out as $line_out) { |
701 | 701 | //RFC2821 section 4.5.2 |
702 | 702 | if (!empty($line_out) and $line_out[0] == '.') { |
703 | - $line_out = '.' . $line_out; |
|
703 | + $line_out = '.'.$line_out; |
|
704 | 704 | } |
705 | - $this->client_send($line_out . static::LE, 'DATA'); |
|
705 | + $this->client_send($line_out.static::LE, 'DATA'); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | protected function sendHello($hello, $host) |
750 | 750 | { |
751 | - $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); |
|
751 | + $noerror = $this->sendCommand($hello, $hello.' '.$host, 250); |
|
752 | 752 | $this->helo_rply = $this->last_reply; |
753 | 753 | if ($noerror) { |
754 | 754 | $this->parseHelloFields($hello); |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | |
820 | 820 | return $this->sendCommand( |
821 | 821 | 'MAIL FROM', |
822 | - 'MAIL FROM:<' . $from . '>' . $useVerp, |
|
822 | + 'MAIL FROM:<'.$from.'>'.$useVerp, |
|
823 | 823 | 250 |
824 | 824 | ); |
825 | 825 | } |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | { |
860 | 860 | return $this->sendCommand( |
861 | 861 | 'RCPT TO', |
862 | - 'RCPT TO:<' . $address . '>', |
|
862 | + 'RCPT TO:<'.$address.'>', |
|
863 | 863 | [250, 251] |
864 | 864 | ); |
865 | 865 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | |
899 | 899 | return false; |
900 | 900 | } |
901 | - $this->client_send($commandstring . static::LE, $command); |
|
901 | + $this->client_send($commandstring.static::LE, $command); |
|
902 | 902 | |
903 | 903 | $this->last_reply = $this->get_lines(); |
904 | 904 | // Fetch SMTP code and possible error code explanation |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | $code_ex = (count($matches) > 2 ? $matches[2] : null); |
909 | 909 | // Cut off error code from each response line |
910 | 910 | $detail = preg_replace( |
911 | - "/{$code}[ -]" . |
|
912 | - ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m', |
|
911 | + "/{$code}[ -]". |
|
912 | + ($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '').'/m', |
|
913 | 913 | '', |
914 | 914 | $this->last_reply |
915 | 915 | ); |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $detail = substr($this->last_reply, 4); |
921 | 921 | } |
922 | 922 | |
923 | - $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); |
|
923 | + $this->edebug('SERVER -> CLIENT: '.$this->last_reply, self::DEBUG_SERVER); |
|
924 | 924 | |
925 | 925 | if (!in_array($code, (array) $expect)) { |
926 | 926 | $this->setError( |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $code_ex |
931 | 931 | ); |
932 | 932 | $this->edebug( |
933 | - 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, |
|
933 | + 'SMTP ERROR: '.$this->error['error'].': '.$this->last_reply, |
|
934 | 934 | self::DEBUG_CLIENT |
935 | 935 | ); |
936 | 936 | |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | public function turn() |
997 | 997 | { |
998 | 998 | $this->setError('The SMTP TURN command is not implemented'); |
999 | - $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); |
|
999 | + $this->edebug('SMTP NOTICE: '.$this->error['error'], self::DEBUG_CLIENT); |
|
1000 | 1000 | |
1001 | 1001 | return false; |
1002 | 1002 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | in_array($command, ['User & Password', 'Username', 'Password'], true)) { |
1018 | 1018 | $this->edebug('CLIENT -> SERVER: <credentials hidden>', self::DEBUG_CLIENT); |
1019 | 1019 | } else { |
1020 | - $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT); |
|
1020 | + $this->edebug('CLIENT -> SERVER: '.$data, self::DEBUG_CLIENT); |
|
1021 | 1021 | } |
1022 | 1022 | set_error_handler([$this, 'errorHandler']); |
1023 | 1023 | $result = fwrite($this->smtp_conn, $data); |
@@ -1123,14 +1123,14 @@ discard block |
||
1123 | 1123 | //Must pass vars in here as params are by reference |
1124 | 1124 | if (!stream_select($selR, $selW, $selW, $this->Timelimit)) { |
1125 | 1125 | $this->edebug( |
1126 | - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', |
|
1126 | + 'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)', |
|
1127 | 1127 | self::DEBUG_LOWLEVEL |
1128 | 1128 | ); |
1129 | 1129 | break; |
1130 | 1130 | } |
1131 | 1131 | //Deliberate noise suppression - errors are handled afterwards |
1132 | 1132 | $str = @fgets($this->smtp_conn, 515); |
1133 | - $this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL); |
|
1133 | + $this->edebug('SMTP INBOUND: "'.trim($str).'"', self::DEBUG_LOWLEVEL); |
|
1134 | 1134 | $data .= $str; |
1135 | 1135 | // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), |
1136 | 1136 | // or 4th character is a space, we are done reading, break the loop, |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | $info = stream_get_meta_data($this->smtp_conn); |
1143 | 1143 | if ($info['timed_out']) { |
1144 | 1144 | $this->edebug( |
1145 | - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', |
|
1145 | + 'SMTP -> get_lines(): timed-out ('.$this->Timeout.' sec)', |
|
1146 | 1146 | self::DEBUG_LOWLEVEL |
1147 | 1147 | ); |
1148 | 1148 | break; |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | // Now check if reads took too long |
1151 | 1151 | if ($endtime and time() > $endtime) { |
1152 | 1152 | $this->edebug( |
1153 | - 'SMTP -> get_lines(): timelimit reached (' . |
|
1154 | - $this->Timelimit . ' sec)', |
|
1153 | + 'SMTP -> get_lines(): timelimit reached ('. |
|
1154 | + $this->Timelimit.' sec)', |
|
1155 | 1155 | self::DEBUG_LOWLEVEL |
1156 | 1156 | ); |
1157 | 1157 | break; |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | protected function sendCommand($command, $commandstring, $expect) |
889 | 889 | { |
890 | 890 | if (!$this->connected()) { |
891 | - $this->setError("Called $command without being connected"); |
|
891 | + $this->setError("called $command without being connected"); |
|
892 | 892 | |
893 | 893 | return false; |
894 | 894 | } |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | */ |
971 | 971 | public function verify($name) |
972 | 972 | { |
973 | - return $this->sendCommand('VRFY', "VRFY $name", [250, 251]); |
|
973 | + return $this->sendCommand('VRFY', "vrfy $name", [250, 251]); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |