@@ -32,6 +32,9 @@ |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | +/** |
|
36 | + * @param string $src |
|
37 | + */ |
|
35 | 38 | function parse($src,$ph,$left='[+',$right='+]') |
36 | 39 | { |
37 | 40 | foreach($ph as $k=>$v) |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function install_sessionCheck() |
3 | 3 | { |
4 | - global $_lang; |
|
4 | + global $_lang; |
|
5 | 5 | |
6 | - // session loop-back tester |
|
7 | - if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
8 | - { |
|
9 | - if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
10 | - { |
|
11 | - echo ' |
|
6 | + // session loop-back tester |
|
7 | + if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
8 | + { |
|
9 | + if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
10 | + { |
|
11 | + echo ' |
|
12 | 12 | <html> |
13 | 13 | <head> |
14 | 14 | <title>Install Problem</title> |
@@ -27,86 +27,86 @@ discard block |
||
27 | 27 | </div> |
28 | 28 | </body> |
29 | 29 | </html>'; |
30 | - exit; |
|
31 | - } |
|
32 | - } |
|
30 | + exit; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function parse($src,$ph,$left='[+',$right='+]') |
36 | 36 | { |
37 | - foreach($ph as $k=>$v) |
|
38 | - { |
|
39 | - $k = $left . $k . $right; |
|
40 | - $src = str_replace($k,$v,$src); |
|
41 | - } |
|
42 | - return $src; |
|
37 | + foreach($ph as $k=>$v) |
|
38 | + { |
|
39 | + $k = $left . $k . $right; |
|
40 | + $src = str_replace($k,$v,$src); |
|
41 | + } |
|
42 | + return $src; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function ph() |
46 | 46 | { |
47 | - global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
|
47 | + global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
|
48 | 48 | |
49 | - if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
50 | - else $installmode = get_installmode(); |
|
49 | + if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
50 | + else $installmode = get_installmode(); |
|
51 | 51 | |
52 | - $ph['pagetitle'] = $_lang['modx_install']; |
|
53 | - $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
|
54 | - $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
|
55 | - $ph['version'] = $moduleVersion; |
|
56 | - $ph['release_date'] = ($modx_textdir ? '‏':'') . $modx_release_date; |
|
57 | - $ph['footer1'] = $_lang['modx_footer1']; |
|
58 | - $ph['footer2'] = $_lang['modx_footer2']; |
|
59 | - $ph['current_year'] = date('Y'); |
|
60 | - return $ph; |
|
52 | + $ph['pagetitle'] = $_lang['modx_install']; |
|
53 | + $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
|
54 | + $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
|
55 | + $ph['version'] = $moduleVersion; |
|
56 | + $ph['release_date'] = ($modx_textdir ? '‏':'') . $modx_release_date; |
|
57 | + $ph['footer1'] = $_lang['modx_footer1']; |
|
58 | + $ph['footer2'] = $_lang['modx_footer2']; |
|
59 | + $ph['current_year'] = date('Y'); |
|
60 | + return $ph; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function get_installmode() |
64 | 64 | { |
65 | - global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
|
65 | + global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
|
66 | 66 | |
67 | - $conf_path = "{$base_path}manager/includes/config.inc.php"; |
|
68 | - if (!is_file($conf_path)) $installmode = 0; |
|
69 | - elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
70 | - else |
|
71 | - { |
|
72 | - include_once("{$base_path}manager/includes/config.inc.php"); |
|
67 | + $conf_path = "{$base_path}manager/includes/config.inc.php"; |
|
68 | + if (!is_file($conf_path)) $installmode = 0; |
|
69 | + elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
70 | + else |
|
71 | + { |
|
72 | + include_once("{$base_path}manager/includes/config.inc.php"); |
|
73 | 73 | |
74 | - if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
75 | - else |
|
76 | - { |
|
77 | - $conn = mysqli_connect($database_server, $database_user, $database_password); |
|
78 | - if($conn) |
|
79 | - { |
|
80 | - $_SESSION['database_server'] = $database_server; |
|
81 | - $_SESSION['database_user'] = $database_user; |
|
82 | - $_SESSION['database_password'] = $database_password; |
|
74 | + if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
75 | + else |
|
76 | + { |
|
77 | + $conn = mysqli_connect($database_server, $database_user, $database_password); |
|
78 | + if($conn) |
|
79 | + { |
|
80 | + $_SESSION['database_server'] = $database_server; |
|
81 | + $_SESSION['database_user'] = $database_user; |
|
82 | + $_SESSION['database_password'] = $database_password; |
|
83 | 83 | |
84 | - $dbase = trim($dbase, '`'); |
|
85 | - $rs = mysqli_select_db($conn, $dbase); |
|
86 | - } |
|
87 | - else $rs = false; |
|
84 | + $dbase = trim($dbase, '`'); |
|
85 | + $rs = mysqli_select_db($conn, $dbase); |
|
86 | + } |
|
87 | + else $rs = false; |
|
88 | 88 | |
89 | - if($rs) |
|
90 | - { |
|
91 | - $_SESSION['dbase'] = $dbase; |
|
92 | - $_SESSION['table_prefix'] = $table_prefix; |
|
93 | - $_SESSION['database_collation'] = 'utf8_general_ci'; |
|
94 | - $_SESSION['database_connection_method'] = 'SET CHARACTER SET'; |
|
89 | + if($rs) |
|
90 | + { |
|
91 | + $_SESSION['dbase'] = $dbase; |
|
92 | + $_SESSION['table_prefix'] = $table_prefix; |
|
93 | + $_SESSION['database_collation'] = 'utf8_general_ci'; |
|
94 | + $_SESSION['database_connection_method'] = 'SET CHARACTER SET'; |
|
95 | 95 | |
96 | - $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
|
97 | - $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
|
98 | - if($rs) |
|
99 | - { |
|
100 | - $row = mysqli_fetch_assoc($rs); |
|
101 | - $settings_version = $row['setting_value']; |
|
102 | - } |
|
103 | - else $settings_version = ''; |
|
96 | + $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
|
97 | + $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
|
98 | + if($rs) |
|
99 | + { |
|
100 | + $row = mysqli_fetch_assoc($rs); |
|
101 | + $settings_version = $row['setting_value']; |
|
102 | + } |
|
103 | + else $settings_version = ''; |
|
104 | 104 | |
105 | - if (empty($settings_version)) $installmode = 0; |
|
106 | - else $installmode = 1; |
|
107 | - } |
|
108 | - else $installmode = 1; |
|
109 | - } |
|
110 | - } |
|
111 | - return $installmode; |
|
105 | + if (empty($settings_version)) $installmode = 0; |
|
106 | + else $installmode = 1; |
|
107 | + } |
|
108 | + else $installmode = 1; |
|
109 | + } |
|
110 | + } |
|
111 | + return $installmode; |
|
112 | 112 | } |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | global $_lang; |
5 | 5 | |
6 | 6 | // session loop-back tester |
7 | - if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
7 | + if (!isset($_GET['action']) || $_GET['action'] !== 'mode') |
|
8 | 8 | { |
9 | - if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
9 | + if (!isset($_SESSION['test']) || $_SESSION['test'] != 1) |
|
10 | 10 | { |
11 | 11 | echo ' |
12 | 12 | <html> |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | </head> |
23 | 23 | <body> |
24 | 24 | <div class="install"> |
25 | - <p>' . $_lang["session_problem"] . '</p> |
|
26 | - <p><a href="./">' .$_lang["session_problem_try_again"] . '</a></p> |
|
25 | + <p>' . $_lang["session_problem"].'</p> |
|
26 | + <p><a href="./">' .$_lang["session_problem_try_again"].'</a></p> |
|
27 | 27 | </div> |
28 | 28 | </body> |
29 | 29 | </html>'; |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -function parse($src,$ph,$left='[+',$right='+]') |
|
35 | +function parse($src, $ph, $left = '[+', $right = '+]') |
|
36 | 36 | { |
37 | - foreach($ph as $k=>$v) |
|
37 | + foreach ($ph as $k=>$v) |
|
38 | 38 | { |
39 | - $k = $left . $k . $right; |
|
40 | - $src = str_replace($k,$v,$src); |
|
39 | + $k = $left.$k.$right; |
|
40 | + $src = str_replace($k, $v, $src); |
|
41 | 41 | } |
42 | 42 | return $src; |
43 | 43 | } |
44 | 44 | |
45 | 45 | function ph() |
46 | 46 | { |
47 | - global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
|
47 | + global $_lang, $moduleName, $moduleVersion, $modx_textdir, $modx_release_date; |
|
48 | 48 | |
49 | - if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
49 | + if (isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
50 | 50 | else $installmode = get_installmode(); |
51 | 51 | |
52 | 52 | $ph['pagetitle'] = $_lang['modx_install']; |
53 | - $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
|
53 | + $ph['textdir'] = $modx_textdir ? ' id="rtl"' : ''; |
|
54 | 54 | $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
55 | 55 | $ph['version'] = $moduleVersion; |
56 | - $ph['release_date'] = ($modx_textdir ? '‏':'') . $modx_release_date; |
|
56 | + $ph['release_date'] = ($modx_textdir ? '‏' : '').$modx_release_date; |
|
57 | 57 | $ph['footer1'] = $_lang['modx_footer1']; |
58 | 58 | $ph['footer2'] = $_lang['modx_footer2']; |
59 | 59 | $ph['current_year'] = date('Y'); |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | |
63 | 63 | function get_installmode() |
64 | 64 | { |
65 | - global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
|
65 | + global $base_path, $database_server, $database_user, $database_password, $dbase, $table_prefix; |
|
66 | 66 | |
67 | 67 | $conf_path = "{$base_path}manager/includes/config.inc.php"; |
68 | 68 | if (!is_file($conf_path)) $installmode = 0; |
69 | - elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
69 | + elseif (isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
70 | 70 | else |
71 | 71 | { |
72 | 72 | include_once("{$base_path}manager/includes/config.inc.php"); |
73 | 73 | |
74 | - if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
74 | + if (!isset($dbase) || empty($dbase)) $installmode = 0; |
|
75 | 75 | else |
76 | 76 | { |
77 | 77 | $conn = mysqli_connect($database_server, $database_user, $database_password); |
78 | - if($conn) |
|
78 | + if ($conn) |
|
79 | 79 | { |
80 | 80 | $_SESSION['database_server'] = $database_server; |
81 | 81 | $_SESSION['database_user'] = $database_user; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | else $rs = false; |
88 | 88 | |
89 | - if($rs) |
|
89 | + if ($rs) |
|
90 | 90 | { |
91 | 91 | $_SESSION['dbase'] = $dbase; |
92 | 92 | $_SESSION['table_prefix'] = $table_prefix; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
97 | 97 | $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
98 | - if($rs) |
|
98 | + if ($rs) |
|
99 | 99 | { |
100 | 100 | $row = mysqli_fetch_assoc($rs); |
101 | 101 | $settings_version = $row['setting_value']; |
@@ -4,10 +4,8 @@ discard block |
||
4 | 4 | global $_lang; |
5 | 5 | |
6 | 6 | // session loop-back tester |
7 | - if(!isset($_GET['action']) || $_GET['action']!=='mode') |
|
8 | - { |
|
9 | - if(!isset($_SESSION['test']) || $_SESSION['test']!=1) |
|
10 | - { |
|
7 | + if(!isset($_GET['action']) || $_GET['action']!=='mode') { |
|
8 | + if(!isset($_SESSION['test']) || $_SESSION['test']!=1) { |
|
11 | 9 | echo ' |
12 | 10 | <html> |
13 | 11 | <head> |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | |
35 | 33 | function parse($src,$ph,$left='[+',$right='+]') |
36 | 34 | { |
37 | - foreach($ph as $k=>$v) |
|
38 | - { |
|
35 | + foreach($ph as $k=>$v) { |
|
39 | 36 | $k = $left . $k . $right; |
40 | 37 | $src = str_replace($k,$v,$src); |
41 | 38 | } |
@@ -46,8 +43,11 @@ discard block |
||
46 | 43 | { |
47 | 44 | global $_lang,$moduleName,$moduleVersion,$modx_textdir,$modx_release_date; |
48 | 45 | |
49 | - if(isset($_SESSION['installmode'])) $installmode = $_SESSION['installmode']; |
|
50 | - else $installmode = get_installmode(); |
|
46 | + if(isset($_SESSION['installmode'])) { |
|
47 | + $installmode = $_SESSION['installmode']; |
|
48 | + } else { |
|
49 | + $installmode = get_installmode(); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | $ph['pagetitle'] = $_lang['modx_install']; |
53 | 53 | $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; |
@@ -65,29 +65,29 @@ discard block |
||
65 | 65 | global $base_path,$database_server, $database_user, $database_password, $dbase, $table_prefix; |
66 | 66 | |
67 | 67 | $conf_path = "{$base_path}manager/includes/config.inc.php"; |
68 | - if (!is_file($conf_path)) $installmode = 0; |
|
69 | - elseif(isset($_POST['installmode'])) $installmode = $_POST['installmode']; |
|
70 | - else |
|
71 | - { |
|
68 | + if (!is_file($conf_path)) { |
|
69 | + $installmode = 0; |
|
70 | + } elseif(isset($_POST['installmode'])) { |
|
71 | + $installmode = $_POST['installmode']; |
|
72 | + } else { |
|
72 | 73 | include_once("{$base_path}manager/includes/config.inc.php"); |
73 | 74 | |
74 | - if(!isset($dbase) || empty($dbase)) $installmode = 0; |
|
75 | - else |
|
76 | - { |
|
75 | + if(!isset($dbase) || empty($dbase)) { |
|
76 | + $installmode = 0; |
|
77 | + } else { |
|
77 | 78 | $conn = mysqli_connect($database_server, $database_user, $database_password); |
78 | - if($conn) |
|
79 | - { |
|
79 | + if($conn) { |
|
80 | 80 | $_SESSION['database_server'] = $database_server; |
81 | 81 | $_SESSION['database_user'] = $database_user; |
82 | 82 | $_SESSION['database_password'] = $database_password; |
83 | 83 | |
84 | 84 | $dbase = trim($dbase, '`'); |
85 | 85 | $rs = mysqli_select_db($conn, $dbase); |
86 | + } else { |
|
87 | + $rs = false; |
|
86 | 88 | } |
87 | - else $rs = false; |
|
88 | 89 | |
89 | - if($rs) |
|
90 | - { |
|
90 | + if($rs) { |
|
91 | 91 | $_SESSION['dbase'] = $dbase; |
92 | 92 | $_SESSION['table_prefix'] = $table_prefix; |
93 | 93 | $_SESSION['database_collation'] = 'utf8_general_ci'; |
@@ -95,17 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | $tbl_system_settings = "`{$dbase}`.`{$table_prefix}system_settings`"; |
97 | 97 | $rs = mysqli_query($conn, "SELECT setting_value FROM {$tbl_system_settings} WHERE setting_name='settings_version'"); |
98 | - if($rs) |
|
99 | - { |
|
98 | + if($rs) { |
|
100 | 99 | $row = mysqli_fetch_assoc($rs); |
101 | 100 | $settings_version = $row['setting_value']; |
101 | + } else { |
|
102 | + $settings_version = ''; |
|
102 | 103 | } |
103 | - else $settings_version = ''; |
|
104 | 104 | |
105 | - if (empty($settings_version)) $installmode = 0; |
|
106 | - else $installmode = 1; |
|
105 | + if (empty($settings_version)) { |
|
106 | + $installmode = 0; |
|
107 | + } else { |
|
108 | + $installmode = 1; |
|
109 | + } |
|
110 | + } else { |
|
111 | + $installmode = 1; |
|
107 | 112 | } |
108 | - else $installmode = 1; |
|
109 | 113 | } |
110 | 114 | } |
111 | 115 | return $installmode; |
@@ -520,6 +520,9 @@ discard block |
||
520 | 520 | $this->setDroptables(false); |
521 | 521 | } |
522 | 522 | |
523 | + /** |
|
524 | + * @param boolean $state |
|
525 | + */ |
|
523 | 526 | function setDroptables($state) |
524 | 527 | { |
525 | 528 | $this->_isDroptables = $state; |
@@ -734,6 +737,9 @@ discard block |
||
734 | 737 | $_SESSION['result_msg'] = $result_code; |
735 | 738 | } |
736 | 739 | |
740 | +/** |
|
741 | + * @param string $dumpstring |
|
742 | + */ |
|
737 | 743 | function dumpSql(&$dumpstring) |
738 | 744 | { |
739 | 745 | global $modx; |
@@ -753,6 +759,9 @@ discard block |
||
753 | 759 | return true; |
754 | 760 | } |
755 | 761 | |
762 | +/** |
|
763 | + * @param string $dumpstring |
|
764 | + */ |
|
756 | 765 | function snapshot(&$dumpstring) |
757 | 766 | { |
758 | 767 | global $path; |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | $dbase = trim($dbase, '`'); |
10 | 10 | |
11 | 11 | if (!isset($modx->config['snapshot_path'])) { |
12 | - if (is_dir(MODX_BASE_PATH . 'temp/backup/')) { |
|
13 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'temp/backup/'; |
|
12 | + if (is_dir(MODX_BASE_PATH.'temp/backup/')) { |
|
13 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'temp/backup/'; |
|
14 | 14 | } else { |
15 | - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'assets/backup/'; |
|
15 | + $modx->config['snapshot_path'] = MODX_BASE_PATH.'assets/backup/'; |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | if ($mode == 'restore1') { |
24 | 24 | if (isset($_POST['textarea']) && !empty($_POST['textarea'])) { |
25 | 25 | $source = trim($_POST['textarea']); |
26 | - $_SESSION['textarea'] = $source . "\n"; |
|
26 | + $_SESSION['textarea'] = $source."\n"; |
|
27 | 27 | } else { |
28 | 28 | $source = file_get_contents($_FILES['sqlfile']['tmp_name']); |
29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | header('Location: index.php?r=9&a=93'); |
32 | 32 | exit; |
33 | 33 | } elseif ($mode == 'restore2') { |
34 | - $path = $modx->config['snapshot_path'] . $_POST['filename']; |
|
34 | + $path = $modx->config['snapshot_path'].$_POST['filename']; |
|
35 | 35 | if (file_exists($path)) { |
36 | 36 | $source = file_get_contents($path); |
37 | 37 | import_sql($source); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if (!is_writable(rtrim($modx->config['snapshot_path'], '/'))) { |
78 | 78 | $modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); |
79 | 79 | } |
80 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
80 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
81 | 81 | $rs = $modx->db->query($sql); |
82 | 82 | $tables = $modx->db->getColumn('Name', $rs); |
83 | 83 | //$today = $modx->toDateFormat(time()); |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | $modx->webAlertAndQuit('Unable to Backup Database'); |
114 | 114 | } |
115 | 115 | } else { |
116 | - include_once MODX_MANAGER_PATH . "includes/header.inc.php"; // start normal header |
|
116 | + include_once MODX_MANAGER_PATH."includes/header.inc.php"; // start normal header |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | if (isset($_SESSION['result_msg']) && $_SESSION['result_msg'] != '') { |
120 | 120 | switch ($_SESSION['result_msg']) { |
121 | 121 | case 'import_ok': |
122 | - $ph['result_msg_import'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
123 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_import_ok"] . '</div>'; |
|
122 | + $ph['result_msg_import'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
123 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_import_ok"].'</div>'; |
|
124 | 124 | break; |
125 | 125 | case 'snapshot_ok': |
126 | 126 | $ph['result_msg_import'] = ''; |
127 | - $ph['result_msg_snapshot'] = '<div class="alert alert-success">' . $_lang["bkmgr_snapshot_ok"] . '</div>'; |
|
127 | + $ph['result_msg_snapshot'] = '<div class="alert alert-success">'.$_lang["bkmgr_snapshot_ok"].'</div>'; |
|
128 | 128 | break; |
129 | 129 | } |
130 | 130 | $_SESSION['result_msg'] = ''; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | f.style.display = 'none'; |
184 | 184 | } |
185 | 185 | } |
186 | - <?= (isset($_REQUEST['r']) ? " doRefresh(" . $_REQUEST['r'] . ");" : "") ?> |
|
186 | + <?= (isset($_REQUEST['r']) ? " doRefresh(".$_REQUEST['r'].");" : "") ?> |
|
187 | 187 | |
188 | 188 | </script> |
189 | 189 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | </thead> |
228 | 228 | <tbody> |
229 | 229 | <?php |
230 | - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; |
|
230 | + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '".$modx->db->escape($modx->db->config['table_prefix'])."%'"; |
|
231 | 231 | $rs = $modx->db->query($sql); |
232 | 232 | $i = 0; |
233 | 233 | while ($db_status = $modx->db->getRow($rs)) { |
@@ -237,29 +237,29 @@ discard block |
||
237 | 237 | $table_string = ''; |
238 | 238 | } |
239 | 239 | |
240 | - echo '<tr>' . "\n" . '<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="' . $db_status['Name'] . '"' . (strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"') . ' /><b class="text-primary">' . $db_status['Name'] . '</b></label></td>' . "\n"; |
|
241 | - echo '<td class="text-xs-center">' . (!empty($db_status['Comment']) ? '<i class="' . $_style['actions_help'] . '" data-tooltip="' . $db_status['Comment'] . '"></i>' : '') . '</td>' . "\n"; |
|
242 | - echo '<td class="text-xs-right">' . $db_status['Rows'] . '</td>' . "\n"; |
|
243 | - echo '<td class="text-xs-right">' . $db_status['Collation'] . '</td>' . "\n"; |
|
240 | + echo '<tr>'."\n".'<td><label class="form-check form-check-label"><input type="checkbox" name="chk[]" class="form-check-input" value="'.$db_status['Name'].'"'.(strstr($table_string, $db_status['Name']) === false ? '' : ' checked="checked"').' /><b class="text-primary">'.$db_status['Name'].'</b></label></td>'."\n"; |
|
241 | + echo '<td class="text-xs-center">'.(!empty($db_status['Comment']) ? '<i class="'.$_style['actions_help'].'" data-tooltip="'.$db_status['Comment'].'"></i>' : '').'</td>'."\n"; |
|
242 | + echo '<td class="text-xs-right">'.$db_status['Rows'].'</td>'."\n"; |
|
243 | + echo '<td class="text-xs-right">'.$db_status['Collation'].'</td>'."\n"; |
|
244 | 244 | |
245 | 245 | // Enable record deletion for certain tables (TRUNCATE TABLE) if they're not already empty |
246 | 246 | $truncateable = array( |
247 | - $modx->db->config['table_prefix'] . 'event_log', |
|
248 | - $modx->db->config['table_prefix'] . 'manager_log', |
|
247 | + $modx->db->config['table_prefix'].'event_log', |
|
248 | + $modx->db->config['table_prefix'].'manager_log', |
|
249 | 249 | ); |
250 | 250 | if ($modx->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) { |
251 | - echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode=' . $action . '&u=' . $db_status['Name'] . '" title="' . $_lang['truncate_table'] . '">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</a>' . '</td>' . "\n"; |
|
251 | + echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode='.$action.'&u='.$db_status['Name'].'" title="'.$_lang['truncate_table'].'">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</a>'.'</td>'."\n"; |
|
252 | 252 | } else { |
253 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n"; |
|
253 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if ($modx->hasPermission('settings')) { |
257 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode=' . $action . '&t=' . $db_status['Name'] . '" title="' . $_lang['optimize_table'] . '">' . $modx->nicesize($db_status['Data_free']) . '</a>' : '-') . '</td>' . "\n"; |
|
257 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode='.$action.'&t='.$db_status['Name'].'" title="'.$_lang['optimize_table'].'">'.$modx->nicesize($db_status['Data_free']).'</a>' : '-').'</td>'."\n"; |
|
258 | 258 | } else { |
259 | - echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-') . '</td>' . "\n"; |
|
259 | + echo '<td class="text-xs-right">'.($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-').'</td>'."\n"; |
|
260 | 260 | } |
261 | 261 | |
262 | - echo '<td class="text-xs-right">' . $modx->nicesize($db_status['Data_length'] - $db_status['Data_free']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length']) . '</td>' . "\n" . '<td class="text-xs-right">' . $modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n" . "</tr>"; |
|
262 | + echo '<td class="text-xs-right">'.$modx->nicesize($db_status['Data_length'] - $db_status['Data_free']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length']).'</td>'."\n".'<td class="text-xs-right">'.$modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']).'</td>'."\n"."</tr>"; |
|
263 | 263 | |
264 | 264 | $total = $total + $db_status['Index_length'] + $db_status['Data_length']; |
265 | 265 | $totaloverhead = $totaloverhead + $db_status['Data_free']; |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | <tr> |
271 | 271 | <td class="text-xs-right"><?= $_lang['database_table_totals'] ?></td> |
272 | 272 | <td colspan="4"> </td> |
273 | - <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">' . $modx->nicesize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-' ?></td> |
|
273 | + <td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">'.$modx->nicesize($totaloverhead).'</b><br />('.number_format($totaloverhead).' B)' : '-' ?></td> |
|
274 | 274 | <td colspan="2"> </td> |
275 | - <td class="text-xs-right"><?= "<b>" . $modx->nicesize($total) . "</b><br />(" . number_format($total) . " B)" ?></td> |
|
275 | + <td class="text-xs-right"><?= "<b>".$modx->nicesize($total)."</b><br />(".number_format($total)." B)" ?></td> |
|
276 | 276 | </tr> |
277 | 277 | </tfoot> |
278 | 278 | </table> |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | foreach ($last_result['0'] as $k => $v) { |
324 | 324 | $title[] = $k; |
325 | 325 | } |
326 | - $result = '<thead><tr><th>' . implode('</th><th>', $title) . '</th></tr></thead>'; |
|
326 | + $result = '<thead><tr><th>'.implode('</th><th>', $title).'</th></tr></thead>'; |
|
327 | 327 | $result .= '<tbody>'; |
328 | 328 | foreach ($last_result as $row) { |
329 | 329 | $result_value = array(); |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | foreach ($row as $k => $v) { |
332 | 332 | $result_value[] = $v; |
333 | 333 | } |
334 | - $result .= '<tr><td>' . implode('</td><td>', $result_value) . '</td></tr>'; |
|
334 | + $result .= '<tr><td>'.implode('</td><td>', $result_value).'</td></tr>'; |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | $result .= '</tbody>'; |
338 | - $result = '<table class="table data">' . $result . '</table>'; |
|
338 | + $result = '<table class="table data">'.$result.'</table>'; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | while ($count < 11) { |
438 | 438 | $line = fgets($file); |
439 | 439 | foreach ($detailFields as $label) { |
440 | - $fileLabel = '# ' . $label; |
|
440 | + $fileLabel = '# '.$label; |
|
441 | 441 | if (strpos($line, $fileLabel) !== false) { |
442 | 442 | $details[$label] = htmlentities(trim(str_replace(array( |
443 | 443 | $fileLabel, |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | }; |
451 | 451 | fclose($file); |
452 | 452 | |
453 | - $tooltip = "Generation Time: " . $details["Generation Time"] . "\n"; |
|
454 | - $tooltip .= "Server version: " . $details["Server version"] . "\n"; |
|
455 | - $tooltip .= "PHP Version: " . $details["PHP Version"] . "\n"; |
|
456 | - $tooltip .= "Host: " . $details["Host"] . "\n"; |
|
453 | + $tooltip = "Generation Time: ".$details["Generation Time"]."\n"; |
|
454 | + $tooltip .= "Server version: ".$details["Server version"]."\n"; |
|
455 | + $tooltip .= "PHP Version: ".$details["PHP Version"]."\n"; |
|
456 | + $tooltip .= "Host: ".$details["Host"]."\n"; |
|
457 | 457 | ?> |
458 | 458 | <tr> |
459 | 459 | <td><?= $filename ?></td> |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | <?php |
486 | 486 | |
487 | 487 | if (is_numeric($_GET['tab'])) { |
488 | - echo '<script type="text/javascript">tpDBM.setSelectedIndex( ' . $_GET['tab'] . ' );</script>'; |
|
488 | + echo '<script type="text/javascript">tpDBM.setSelectedIndex( '.$_GET['tab'].' );</script>'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | include_once "footer.inc.php"; // send footer |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | |
539 | 539 | // Set line feed |
540 | 540 | $lf = "\n"; |
541 | - $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; |
|
541 | + $tempfile_path = $modx->config['base_path'].'assets/backup/temp.php'; |
|
542 | 542 | |
543 | 543 | $result = $modx->db->query('SHOW TABLES'); |
544 | 544 | $tables = $this->result2Array(0, $result); |
@@ -551,15 +551,15 @@ discard block |
||
551 | 551 | |
552 | 552 | // Set header |
553 | 553 | $output = "#{$lf}"; |
554 | - $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; |
|
554 | + $output .= "# ".addslashes($modx->config['site_name'])." Database Dump{$lf}"; |
|
555 | 555 | $output .= "# MODX Version:{$version['version']}{$lf}"; |
556 | 556 | $output .= "# {$lf}"; |
557 | 557 | $output .= "# Host: {$this->database_server}{$lf}"; |
558 | - $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; |
|
559 | - $output .= "# Server version: " . $modx->db->getVersion() . $lf; |
|
560 | - $output .= "# PHP Version: " . phpversion() . $lf; |
|
558 | + $output .= "# Generation Time: ".$modx->toDateFormat(time()).$lf; |
|
559 | + $output .= "# Server version: ".$modx->db->getVersion().$lf; |
|
560 | + $output .= "# PHP Version: ".phpversion().$lf; |
|
561 | 561 | $output .= "# Database: `{$this->dbname}`{$lf}"; |
562 | - $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; |
|
562 | + $output .= "# Description: ".trim($_REQUEST['backup_title'])."{$lf}"; |
|
563 | 563 | $output .= "#"; |
564 | 564 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
565 | 565 | $output = ''; |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | case $modx->db->config['table_prefix'].'manager_log': |
586 | 586 | continue 2; |
587 | 587 | }*/ |
588 | - if (!preg_match('@^' . $modx->db->config['table_prefix'] . '@', $tblval)) { |
|
588 | + if (!preg_match('@^'.$modx->db->config['table_prefix'].'@', $tblval)) { |
|
589 | 589 | continue; |
590 | 590 | } |
591 | 591 | } |
@@ -619,9 +619,9 @@ discard block |
||
619 | 619 | ), '\\n', $value); |
620 | 620 | $value = "'{$value}'"; |
621 | 621 | } |
622 | - $insertdump .= $value . ','; |
|
622 | + $insertdump .= $value.','; |
|
623 | 623 | } |
624 | - $output .= rtrim($insertdump, ',') . ");\n"; |
|
624 | + $output .= rtrim($insertdump, ',').");\n"; |
|
625 | 625 | if (1048576 < strlen($output)) { |
626 | 626 | file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); |
627 | 627 | $output = ''; |
@@ -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; |
@@ -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 { |
@@ -855,12 +855,12 @@ discard block |
||
855 | 855 | $userfile['type'] = $_FILES['userfile']['type'][$i]; |
856 | 856 | |
857 | 857 | // this seems to be an upload action. |
858 | - $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
859 | - $path = rtrim($path, '/') . '/' . $userfile['name']; |
|
858 | + $path = $modx->config['site_url'].substr($startpath, strlen($filemanager_path), strlen($startpath)); |
|
859 | + $path = rtrim($path, '/').'/'.$userfile['name']; |
|
860 | 860 | $msg .= $path; |
861 | 861 | if ($userfile['error'] == 0) { |
862 | - $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : ''; |
|
863 | - $msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '</p>'; |
|
862 | + $img = (strpos($userfile['type'], 'image') !== false) ? '<br /><img src="'.$path.'" height="75" />' : ''; |
|
863 | + $msg .= "<p>".$_lang['files_file_type'].$userfile['type'].", ".$modx->nicesize(filesize($userfile['tmp_name'])).$img.'</p>'; |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | $userfilename = $userfile['tmp_name']; |
@@ -868,15 +868,15 @@ discard block |
||
868 | 868 | if (is_uploaded_file($userfilename)) { |
869 | 869 | // file is uploaded file, process it! |
870 | 870 | if (!checkExtension($userfile['name'])) { |
871 | - $msg .= '<p><span class="warning">' . $_lang['files_filetype_notok'] . '</span></p>'; |
|
871 | + $msg .= '<p><span class="warning">'.$_lang['files_filetype_notok'].'</span></p>'; |
|
872 | 872 | } else { |
873 | - if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { |
|
873 | + if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'].'/'.$userfile['name'])) { |
|
874 | 874 | // Ryan: Repair broken permissions issue with file manager |
875 | 875 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
876 | - @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); |
|
876 | + @chmod($_POST['path']."/".$userfile['name'], $new_file_permissions); |
|
877 | 877 | } |
878 | 878 | // Ryan: End |
879 | - $msg .= '<p><span class="success">' . $_lang['files_upload_ok'] . '</span></p><hr/>'; |
|
879 | + $msg .= '<p><span class="success">'.$_lang['files_upload_ok'].'</span></p><hr/>'; |
|
880 | 880 | |
881 | 881 | // invoke OnFileManagerUpload event |
882 | 882 | $modx->invokeEvent('OnFileManagerUpload', array( |
@@ -884,13 +884,13 @@ discard block |
||
884 | 884 | 'filename' => $userfile['name'] |
885 | 885 | )); |
886 | 886 | // Log the change |
887 | - logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); |
|
887 | + logFileChange('upload', $_POST['path'].'/'.$userfile['name']); |
|
888 | 888 | } else { |
889 | - $msg .= '<p><span class="warning">' . $_lang['files_upload_copyfailed'] . '</span> ' . $_lang["files_upload_permissions_error"] . '</p>'; |
|
889 | + $msg .= '<p><span class="warning">'.$_lang['files_upload_copyfailed'].'</span> '.$_lang["files_upload_permissions_error"].'</p>'; |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | } else { |
893 | - $msg .= '<br /><span class="warning"><b>' . $_lang['files_upload_error'] . ':</b>'; |
|
893 | + $msg .= '<br /><span class="warning"><b>'.$_lang['files_upload_error'].':</b>'; |
|
894 | 894 | switch ($userfile['error']) { |
895 | 895 | case 0: //no error; possible file attack! |
896 | 896 | $msg .= $_lang['files_upload_error0']; |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } |
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 @@ |
||
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 | } |
@@ -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); |
@@ -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(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,371 +85,371 @@ 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; |
|
105 | + global $modx; |
|
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 | - } |
|
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 | + } |
|
134 | 134 | |
135 | - $filesfound = 0; |
|
135 | + $filesfound = 0; |
|
136 | 136 | |
137 | - $files = getFiles($filedir); |
|
138 | - $files = pop_index($files); |
|
137 | + $files = getFiles($filedir); |
|
138 | + $files = pop_index($files); |
|
139 | 139 | |
140 | - // no. of files to import |
|
141 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
140 | + // no. of files to import |
|
141 | + $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
142 | 142 | |
143 | - // import files |
|
144 | - if(0 < count($files)) { |
|
145 | - $rs = $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
146 | - importFiles($parent, $filedir, $files, 'root'); |
|
147 | - } |
|
143 | + // import files |
|
144 | + if(0 < count($files)) { |
|
145 | + $rs = $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
146 | + importFiles($parent, $filedir, $files, 'root'); |
|
147 | + } |
|
148 | 148 | |
149 | - $mtime = microtime(); |
|
150 | - $mtime = explode(' ', $mtime); |
|
151 | - $mtime = $mtime[1] + $mtime[0]; |
|
152 | - $importend = $mtime; |
|
153 | - $totaltime = ($importend - $importstart); |
|
154 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
149 | + $mtime = microtime(); |
|
150 | + $mtime = explode(' ', $mtime); |
|
151 | + $mtime = $mtime[1] + $mtime[0]; |
|
152 | + $importend = $mtime; |
|
153 | + $totaltime = ($importend - $importstart); |
|
154 | + $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
155 | 155 | |
156 | - if($_POST['convert_link'] == 'on') { |
|
157 | - convertLink(); |
|
158 | - } |
|
156 | + if($_POST['convert_link'] == 'on') { |
|
157 | + convertLink(); |
|
158 | + } |
|
159 | 159 | |
160 | - return $output; |
|
160 | + return $output; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function importFiles($parent, $filedir, $files, $mode) { |
164 | - global $modx; |
|
165 | - global $_lang, $allowedfiles; |
|
166 | - global $search_default, $cache_default, $publish_default; |
|
167 | - |
|
168 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
169 | - $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
170 | - |
|
171 | - $createdon = time(); |
|
172 | - $createdby = $modx->getLoginUserID(); |
|
173 | - if(!is_array($files)) { |
|
174 | - return; |
|
175 | - } |
|
176 | - if($_POST['object'] == 'all') { |
|
177 | - $modx->config['default_template'] = '0'; |
|
178 | - $richtext = '0'; |
|
179 | - } else { |
|
180 | - $richtext = '1'; |
|
181 | - } |
|
182 | - |
|
183 | - foreach($files as $id => $value) { |
|
184 | - if(is_array($value)) { |
|
185 | - // create folder |
|
186 | - $alias = $id; |
|
187 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
188 | - $field = array(); |
|
189 | - $field['type'] = 'document'; |
|
190 | - $field['contentType'] = 'text/html'; |
|
191 | - $field['published'] = $publish_default; |
|
192 | - $field['parent'] = $parent; |
|
193 | - $field['alias'] = $modx->stripAlias($alias); |
|
194 | - $field['richtext'] = $richtext; |
|
195 | - $field['template'] = $modx->config['default_template']; |
|
196 | - $field['searchable'] = $search_default; |
|
197 | - $field['cacheable'] = $cache_default; |
|
198 | - $field['createdby'] = $createdby; |
|
199 | - $field['isfolder'] = 1; |
|
200 | - $field['menuindex'] = 1; |
|
201 | - $find = false; |
|
202 | - foreach(array( |
|
203 | - 'index.html', |
|
204 | - 'index.htm' |
|
205 | - ) as $filename) { |
|
206 | - $filepath = $filedir . $alias . '/' . $filename; |
|
207 | - if($find === false && file_exists($filepath)) { |
|
208 | - $file = getFileContent($filepath); |
|
209 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
210 | - |
|
211 | - $date = filemtime($filepath); |
|
212 | - $field['pagetitle'] = $pagetitle; |
|
213 | - $field['longtitle'] = $pagetitle; |
|
214 | - $field['description'] = $description; |
|
215 | - $field['content'] = $modx->db->escape($content); |
|
216 | - $field['createdon'] = $date; |
|
217 | - $field['editedon'] = $date; |
|
218 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
219 | - if($newid) { |
|
220 | - $find = true; |
|
221 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
222 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
223 | - } else { |
|
224 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
225 | - exit; |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - if($find === false) { |
|
230 | - $date = time(); |
|
231 | - $field['pagetitle'] = '---'; |
|
232 | - $field['content'] = ''; |
|
233 | - $field['createdon'] = $date; |
|
234 | - $field['editedon'] = $date; |
|
235 | - $field['hidemenu'] = '1'; |
|
236 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
237 | - if($newid) { |
|
238 | - $find = true; |
|
239 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
240 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
241 | - } else { |
|
242 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
243 | - exit; |
|
244 | - } |
|
245 | - } |
|
246 | - } else { |
|
247 | - // create document |
|
248 | - if($mode == 'sub' && $value == 'index.html') { |
|
249 | - continue; |
|
250 | - } |
|
251 | - $filename = $value; |
|
252 | - $fparts = explode('.', $value); |
|
253 | - $alias = $fparts[0]; |
|
254 | - $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
255 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
256 | - |
|
257 | - if(!in_array($ext, $allowedfiles)) { |
|
258 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
259 | - } else { |
|
260 | - $filepath = $filedir . $filename; |
|
261 | - $file = getFileContent($filepath); |
|
262 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
263 | - |
|
264 | - $date = filemtime($filepath); |
|
265 | - $field = array(); |
|
266 | - $field['type'] = 'document'; |
|
267 | - $field['contentType'] = 'text/html'; |
|
268 | - $field['pagetitle'] = $pagetitle; |
|
269 | - $field['longtitle'] = $pagetitle; |
|
270 | - $field['description'] = $description; |
|
271 | - $field['alias'] = $modx->stripAlias($alias); |
|
272 | - $field['published'] = $publish_default; |
|
273 | - $field['parent'] = $parent; |
|
274 | - $field['content'] = $modx->db->escape($content); |
|
275 | - $field['richtext'] = $richtext; |
|
276 | - $field['template'] = $modx->config['default_template']; |
|
277 | - $field['searchable'] = $search_default; |
|
278 | - $field['cacheable'] = $cache_default; |
|
279 | - $field['createdby'] = $createdby; |
|
280 | - $field['createdon'] = $date; |
|
281 | - $field['editedon'] = $date; |
|
282 | - $field['isfolder'] = 0; |
|
283 | - $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
284 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
285 | - if($newid) { |
|
286 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
287 | - } else { |
|
288 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
289 | - exit; |
|
290 | - } |
|
291 | - |
|
292 | - $is_site_start = false; |
|
293 | - if($filename == 'index.html') { |
|
294 | - $is_site_start = true; |
|
295 | - } |
|
296 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
297 | - $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
298 | - $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
299 | - } |
|
300 | - } |
|
301 | - } |
|
302 | - } |
|
164 | + global $modx; |
|
165 | + global $_lang, $allowedfiles; |
|
166 | + global $search_default, $cache_default, $publish_default; |
|
167 | + |
|
168 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
169 | + $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
170 | + |
|
171 | + $createdon = time(); |
|
172 | + $createdby = $modx->getLoginUserID(); |
|
173 | + if(!is_array($files)) { |
|
174 | + return; |
|
175 | + } |
|
176 | + if($_POST['object'] == 'all') { |
|
177 | + $modx->config['default_template'] = '0'; |
|
178 | + $richtext = '0'; |
|
179 | + } else { |
|
180 | + $richtext = '1'; |
|
181 | + } |
|
182 | + |
|
183 | + foreach($files as $id => $value) { |
|
184 | + if(is_array($value)) { |
|
185 | + // create folder |
|
186 | + $alias = $id; |
|
187 | + printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
188 | + $field = array(); |
|
189 | + $field['type'] = 'document'; |
|
190 | + $field['contentType'] = 'text/html'; |
|
191 | + $field['published'] = $publish_default; |
|
192 | + $field['parent'] = $parent; |
|
193 | + $field['alias'] = $modx->stripAlias($alias); |
|
194 | + $field['richtext'] = $richtext; |
|
195 | + $field['template'] = $modx->config['default_template']; |
|
196 | + $field['searchable'] = $search_default; |
|
197 | + $field['cacheable'] = $cache_default; |
|
198 | + $field['createdby'] = $createdby; |
|
199 | + $field['isfolder'] = 1; |
|
200 | + $field['menuindex'] = 1; |
|
201 | + $find = false; |
|
202 | + foreach(array( |
|
203 | + 'index.html', |
|
204 | + 'index.htm' |
|
205 | + ) as $filename) { |
|
206 | + $filepath = $filedir . $alias . '/' . $filename; |
|
207 | + if($find === false && file_exists($filepath)) { |
|
208 | + $file = getFileContent($filepath); |
|
209 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
210 | + |
|
211 | + $date = filemtime($filepath); |
|
212 | + $field['pagetitle'] = $pagetitle; |
|
213 | + $field['longtitle'] = $pagetitle; |
|
214 | + $field['description'] = $description; |
|
215 | + $field['content'] = $modx->db->escape($content); |
|
216 | + $field['createdon'] = $date; |
|
217 | + $field['editedon'] = $date; |
|
218 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
219 | + if($newid) { |
|
220 | + $find = true; |
|
221 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
222 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
223 | + } else { |
|
224 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
225 | + exit; |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + if($find === false) { |
|
230 | + $date = time(); |
|
231 | + $field['pagetitle'] = '---'; |
|
232 | + $field['content'] = ''; |
|
233 | + $field['createdon'] = $date; |
|
234 | + $field['editedon'] = $date; |
|
235 | + $field['hidemenu'] = '1'; |
|
236 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
237 | + if($newid) { |
|
238 | + $find = true; |
|
239 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
240 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
241 | + } else { |
|
242 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
243 | + exit; |
|
244 | + } |
|
245 | + } |
|
246 | + } else { |
|
247 | + // create document |
|
248 | + if($mode == 'sub' && $value == 'index.html') { |
|
249 | + continue; |
|
250 | + } |
|
251 | + $filename = $value; |
|
252 | + $fparts = explode('.', $value); |
|
253 | + $alias = $fparts[0]; |
|
254 | + $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
255 | + printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
256 | + |
|
257 | + if(!in_array($ext, $allowedfiles)) { |
|
258 | + echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
259 | + } else { |
|
260 | + $filepath = $filedir . $filename; |
|
261 | + $file = getFileContent($filepath); |
|
262 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
263 | + |
|
264 | + $date = filemtime($filepath); |
|
265 | + $field = array(); |
|
266 | + $field['type'] = 'document'; |
|
267 | + $field['contentType'] = 'text/html'; |
|
268 | + $field['pagetitle'] = $pagetitle; |
|
269 | + $field['longtitle'] = $pagetitle; |
|
270 | + $field['description'] = $description; |
|
271 | + $field['alias'] = $modx->stripAlias($alias); |
|
272 | + $field['published'] = $publish_default; |
|
273 | + $field['parent'] = $parent; |
|
274 | + $field['content'] = $modx->db->escape($content); |
|
275 | + $field['richtext'] = $richtext; |
|
276 | + $field['template'] = $modx->config['default_template']; |
|
277 | + $field['searchable'] = $search_default; |
|
278 | + $field['cacheable'] = $cache_default; |
|
279 | + $field['createdby'] = $createdby; |
|
280 | + $field['createdon'] = $date; |
|
281 | + $field['editedon'] = $date; |
|
282 | + $field['isfolder'] = 0; |
|
283 | + $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
284 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
285 | + if($newid) { |
|
286 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
287 | + } else { |
|
288 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
289 | + exit; |
|
290 | + } |
|
291 | + |
|
292 | + $is_site_start = false; |
|
293 | + if($filename == 'index.html') { |
|
294 | + $is_site_start = true; |
|
295 | + } |
|
296 | + if($is_site_start == true && $_POST['reset'] == 'on') { |
|
297 | + $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
298 | + $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
299 | + } |
|
300 | + } |
|
301 | + } |
|
302 | + } |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | function getFiles($directory, $listing = array(), $count = 0) { |
306 | - global $_lang; |
|
307 | - global $filesfound; |
|
308 | - $dummy = $count; |
|
309 | - if($files = scandir($directory)) { |
|
310 | - foreach($files as $file) { |
|
311 | - if($file == '.' || $file == '..') { |
|
312 | - continue; |
|
313 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
314 | - closedir($h); |
|
315 | - $count = -1; |
|
316 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
317 | - } elseif(strpos($file, '.htm') !== false) { |
|
318 | - $listing[$dummy] = $file; |
|
319 | - $dummy = $dummy + 1; |
|
320 | - $filesfound++; |
|
321 | - } |
|
322 | - } |
|
323 | - } else { |
|
324 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
325 | - } |
|
326 | - return ($listing); |
|
306 | + global $_lang; |
|
307 | + global $filesfound; |
|
308 | + $dummy = $count; |
|
309 | + if($files = scandir($directory)) { |
|
310 | + foreach($files as $file) { |
|
311 | + if($file == '.' || $file == '..') { |
|
312 | + continue; |
|
313 | + } elseif($h = @opendir($directory . $file . "/")) { |
|
314 | + closedir($h); |
|
315 | + $count = -1; |
|
316 | + $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
317 | + } elseif(strpos($file, '.htm') !== false) { |
|
318 | + $listing[$dummy] = $file; |
|
319 | + $dummy = $dummy + 1; |
|
320 | + $filesfound++; |
|
321 | + } |
|
322 | + } |
|
323 | + } else { |
|
324 | + echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
325 | + } |
|
326 | + return ($listing); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | function getFileContent($filepath) { |
330 | - global $_lang; |
|
331 | - // get the file |
|
332 | - if(!$buffer = file_get_contents($filepath)) { |
|
333 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
334 | - } else { |
|
335 | - return $buffer; |
|
336 | - } |
|
330 | + global $_lang; |
|
331 | + // get the file |
|
332 | + if(!$buffer = file_get_contents($filepath)) { |
|
333 | + echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
334 | + } else { |
|
335 | + return $buffer; |
|
336 | + } |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | function pop_index($array) { |
340 | - $new_array = array(); |
|
341 | - foreach($array as $k => $v) { |
|
342 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
343 | - $new_array[$k] = $v; |
|
344 | - } else { |
|
345 | - array_unshift($new_array, $v); |
|
346 | - } |
|
347 | - } |
|
348 | - foreach($array as $k => $v) { |
|
349 | - if(is_array($v)) { |
|
350 | - $new_array[$k] = $v; |
|
351 | - } |
|
352 | - } |
|
353 | - return $new_array; |
|
340 | + $new_array = array(); |
|
341 | + foreach($array as $k => $v) { |
|
342 | + if($v !== 'index.html' && $v !== 'index.htm') { |
|
343 | + $new_array[$k] = $v; |
|
344 | + } else { |
|
345 | + array_unshift($new_array, $v); |
|
346 | + } |
|
347 | + } |
|
348 | + foreach($array as $k => $v) { |
|
349 | + if(is_array($v)) { |
|
350 | + $new_array[$k] = $v; |
|
351 | + } |
|
352 | + } |
|
353 | + return $new_array; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | function treatContent($src, $filename, $alias) { |
357 | - global $modx; |
|
358 | - |
|
359 | - $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
360 | - |
|
361 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
362 | - $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
363 | - $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
364 | - } else { |
|
365 | - $pagetitle = $alias; |
|
366 | - } |
|
367 | - if(!$pagetitle) { |
|
368 | - $pagetitle = $alias; |
|
369 | - } |
|
370 | - |
|
371 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
372 | - $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
373 | - $description = str_replace('[*description*]', '', $description); |
|
374 | - } else { |
|
375 | - $description = ''; |
|
376 | - } |
|
377 | - |
|
378 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
379 | - $content = $matches[1]; |
|
380 | - } else { |
|
381 | - $content = $src; |
|
382 | - $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
383 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
384 | - $content = preg_replace($s, $r, $content); |
|
385 | - $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
386 | - } |
|
387 | - $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
388 | - $content = trim($content); |
|
389 | - $pagetitle = $modx->db->escape($pagetitle); |
|
390 | - return array( |
|
391 | - $pagetitle, |
|
392 | - $content, |
|
393 | - $description |
|
394 | - ); |
|
357 | + global $modx; |
|
358 | + |
|
359 | + $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
360 | + |
|
361 | + if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
362 | + $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
363 | + $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
364 | + } else { |
|
365 | + $pagetitle = $alias; |
|
366 | + } |
|
367 | + if(!$pagetitle) { |
|
368 | + $pagetitle = $alias; |
|
369 | + } |
|
370 | + |
|
371 | + if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
372 | + $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
373 | + $description = str_replace('[*description*]', '', $description); |
|
374 | + } else { |
|
375 | + $description = ''; |
|
376 | + } |
|
377 | + |
|
378 | + if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
379 | + $content = $matches[1]; |
|
380 | + } else { |
|
381 | + $content = $src; |
|
382 | + $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
383 | + $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
384 | + $content = preg_replace($s, $r, $content); |
|
385 | + $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
386 | + } |
|
387 | + $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
388 | + $content = trim($content); |
|
389 | + $pagetitle = $modx->db->escape($pagetitle); |
|
390 | + return array( |
|
391 | + $pagetitle, |
|
392 | + $content, |
|
393 | + $description |
|
394 | + ); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | function convertLink() { |
398 | - global $modx; |
|
399 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
400 | - |
|
401 | - $rs = $modx->db->select('id,content', $tbl_site_content); |
|
402 | - while($row = $modx->db->getRow($rs)) { |
|
403 | - $id = $row['id']; |
|
404 | - $array = explode('<a href=', $row['content']); |
|
405 | - $c = 0; |
|
406 | - foreach($array as $v) { |
|
407 | - if($v[0] === '"') { |
|
408 | - $v = substr($v, 1); |
|
409 | - list($href, $v) = explode('"', $v, 2); |
|
410 | - $_ = $href; |
|
411 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
412 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
413 | - } |
|
414 | - if($_[0] === '/') { |
|
415 | - $_ = substr($_, 1); |
|
416 | - } |
|
417 | - $_ = str_replace('/index.html', '.html', $_); |
|
418 | - $level = substr_count($_, '../'); |
|
419 | - if(1 < $level) { |
|
420 | - if(!isset($p[$id])) { |
|
421 | - $p[$id] = $modx->getParentIds($id); |
|
422 | - } |
|
423 | - $k = array_keys($p[$id]); |
|
424 | - while(0 < $level) { |
|
425 | - $dir = array_shift($k); |
|
426 | - $level--; |
|
427 | - } |
|
428 | - if($dir != '') { |
|
429 | - $dir .= '/'; |
|
430 | - } |
|
431 | - } else { |
|
432 | - $dir = ''; |
|
433 | - } |
|
434 | - |
|
435 | - $_ = trim($_, './'); |
|
436 | - if(strpos($_, '/') !== false) { |
|
437 | - $_ = substr($_, strrpos($_, '/')); |
|
438 | - } |
|
439 | - $_ = $dir . str_replace('.html', '', $_); |
|
440 | - if(!isset($target[$_])) { |
|
441 | - $target[$_] = $modx->getIdFromAlias($_); |
|
442 | - } |
|
443 | - $target[$_] = trim($target[$_]); |
|
444 | - if(!empty($target[$_])) { |
|
445 | - $href = '[~' . $target[$_] . '~]'; |
|
446 | - } |
|
447 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
448 | - } |
|
449 | - $c++; |
|
450 | - } |
|
451 | - $content = implode('', $array); |
|
452 | - $f['content'] = $modx->db->escape($content); |
|
453 | - $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
454 | - } |
|
398 | + global $modx; |
|
399 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
400 | + |
|
401 | + $rs = $modx->db->select('id,content', $tbl_site_content); |
|
402 | + while($row = $modx->db->getRow($rs)) { |
|
403 | + $id = $row['id']; |
|
404 | + $array = explode('<a href=', $row['content']); |
|
405 | + $c = 0; |
|
406 | + foreach($array as $v) { |
|
407 | + if($v[0] === '"') { |
|
408 | + $v = substr($v, 1); |
|
409 | + list($href, $v) = explode('"', $v, 2); |
|
410 | + $_ = $href; |
|
411 | + if(strpos($_, $modx->config['site_url']) !== false) { |
|
412 | + $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
413 | + } |
|
414 | + if($_[0] === '/') { |
|
415 | + $_ = substr($_, 1); |
|
416 | + } |
|
417 | + $_ = str_replace('/index.html', '.html', $_); |
|
418 | + $level = substr_count($_, '../'); |
|
419 | + if(1 < $level) { |
|
420 | + if(!isset($p[$id])) { |
|
421 | + $p[$id] = $modx->getParentIds($id); |
|
422 | + } |
|
423 | + $k = array_keys($p[$id]); |
|
424 | + while(0 < $level) { |
|
425 | + $dir = array_shift($k); |
|
426 | + $level--; |
|
427 | + } |
|
428 | + if($dir != '') { |
|
429 | + $dir .= '/'; |
|
430 | + } |
|
431 | + } else { |
|
432 | + $dir = ''; |
|
433 | + } |
|
434 | + |
|
435 | + $_ = trim($_, './'); |
|
436 | + if(strpos($_, '/') !== false) { |
|
437 | + $_ = substr($_, strrpos($_, '/')); |
|
438 | + } |
|
439 | + $_ = $dir . str_replace('.html', '', $_); |
|
440 | + if(!isset($target[$_])) { |
|
441 | + $target[$_] = $modx->getIdFromAlias($_); |
|
442 | + } |
|
443 | + $target[$_] = trim($target[$_]); |
|
444 | + if(!empty($target[$_])) { |
|
445 | + $href = '[~' . $target[$_] . '~]'; |
|
446 | + } |
|
447 | + $array[$c] = '<a href="' . $href . '"' . $v; |
|
448 | + } |
|
449 | + $c++; |
|
450 | + } |
|
451 | + $content = implode('', $array); |
|
452 | + $f['content'] = $modx->db->escape($content); |
|
453 | + $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
454 | + } |
|
455 | 455 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if(IN_MANAGER_MODE != "true") { |
|
2 | +if (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; |
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 | } |
134 | 134 | |
135 | 135 | $filesfound = 0; |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | $files = pop_index($files); |
139 | 139 | |
140 | 140 | // no. of files to import |
141 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
141 | + $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound); |
|
142 | 142 | |
143 | 143 | // import files |
144 | - if(0 < count($files)) { |
|
144 | + if (0 < count($files)) { |
|
145 | 145 | $rs = $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
146 | 146 | importFiles($parent, $filedir, $files, 'root'); |
147 | 147 | } |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | $mtime = $mtime[1] + $mtime[0]; |
152 | 152 | $importend = $mtime; |
153 | 153 | $totaltime = ($importend - $importstart); |
154 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
154 | + $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3)); |
|
155 | 155 | |
156 | - if($_POST['convert_link'] == 'on') { |
|
156 | + if ($_POST['convert_link'] == 'on') { |
|
157 | 157 | convertLink(); |
158 | 158 | } |
159 | 159 | |
160 | 160 | return $output; |
161 | 161 | } |
162 | 162 | |
163 | -function importFiles($parent, $filedir, $files, $mode) { |
|
163 | +function importFiles($parent, $filedir, $files, $mode){ |
|
164 | 164 | global $modx; |
165 | 165 | global $_lang, $allowedfiles; |
166 | 166 | global $search_default, $cache_default, $publish_default; |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | |
171 | 171 | $createdon = time(); |
172 | 172 | $createdby = $modx->getLoginUserID(); |
173 | - if(!is_array($files)) { |
|
173 | + if (!is_array($files)) { |
|
174 | 174 | return; |
175 | 175 | } |
176 | - if($_POST['object'] == 'all') { |
|
176 | + if ($_POST['object'] == 'all') { |
|
177 | 177 | $modx->config['default_template'] = '0'; |
178 | 178 | $richtext = '0'; |
179 | 179 | } else { |
180 | 180 | $richtext = '1'; |
181 | 181 | } |
182 | 182 | |
183 | - foreach($files as $id => $value) { |
|
184 | - if(is_array($value)) { |
|
183 | + foreach ($files as $id => $value) { |
|
184 | + if (is_array($value)) { |
|
185 | 185 | // create folder |
186 | 186 | $alias = $id; |
187 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
187 | + printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias); |
|
188 | 188 | $field = array(); |
189 | 189 | $field['type'] = 'document'; |
190 | 190 | $field['contentType'] = 'text/html'; |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | $field['isfolder'] = 1; |
200 | 200 | $field['menuindex'] = 1; |
201 | 201 | $find = false; |
202 | - foreach(array( |
|
202 | + foreach (array( |
|
203 | 203 | 'index.html', |
204 | 204 | 'index.htm' |
205 | 205 | ) as $filename) { |
206 | - $filepath = $filedir . $alias . '/' . $filename; |
|
207 | - if($find === false && file_exists($filepath)) { |
|
206 | + $filepath = $filedir.$alias.'/'.$filename; |
|
207 | + if ($find === false && file_exists($filepath)) { |
|
208 | 208 | $file = getFileContent($filepath); |
209 | 209 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
210 | 210 | |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | $field['createdon'] = $date; |
217 | 217 | $field['editedon'] = $date; |
218 | 218 | $newid = $modx->db->insert($field, $tbl_site_content); |
219 | - if($newid) { |
|
219 | + if ($newid) { |
|
220 | 220 | $find = true; |
221 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
222 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
221 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
222 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
223 | 223 | } else { |
224 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
224 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
225 | 225 | exit; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |
229 | - if($find === false) { |
|
229 | + if ($find === false) { |
|
230 | 230 | $date = time(); |
231 | 231 | $field['pagetitle'] = '---'; |
232 | 232 | $field['content'] = ''; |
@@ -234,30 +234,30 @@ discard block |
||
234 | 234 | $field['editedon'] = $date; |
235 | 235 | $field['hidemenu'] = '1'; |
236 | 236 | $newid = $modx->db->insert($field, $tbl_site_content); |
237 | - if($newid) { |
|
237 | + if ($newid) { |
|
238 | 238 | $find = true; |
239 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
240 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
239 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
240 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
241 | 241 | } else { |
242 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
242 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
243 | 243 | exit; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } else { |
247 | 247 | // create document |
248 | - if($mode == 'sub' && $value == 'index.html') { |
|
248 | + if ($mode == 'sub' && $value == 'index.html') { |
|
249 | 249 | continue; |
250 | 250 | } |
251 | 251 | $filename = $value; |
252 | 252 | $fparts = explode('.', $value); |
253 | 253 | $alias = $fparts[0]; |
254 | 254 | $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
255 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
255 | + printf("<span>".$_lang['import_site_importing_document']."</span>", $filename); |
|
256 | 256 | |
257 | - if(!in_array($ext, $allowedfiles)) { |
|
258 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
257 | + if (!in_array($ext, $allowedfiles)) { |
|
258 | + echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n"; |
|
259 | 259 | } else { |
260 | - $filepath = $filedir . $filename; |
|
260 | + $filepath = $filedir.$filename; |
|
261 | 261 | $file = getFileContent($filepath); |
262 | 262 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
263 | 263 | |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | $field['isfolder'] = 0; |
283 | 283 | $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
284 | 284 | $newid = $modx->db->insert($field, $tbl_site_content); |
285 | - if($newid) { |
|
286 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
285 | + if ($newid) { |
|
286 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
287 | 287 | } else { |
288 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
288 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
289 | 289 | exit; |
290 | 290 | } |
291 | 291 | |
292 | 292 | $is_site_start = false; |
293 | - if($filename == 'index.html') { |
|
293 | + if ($filename == 'index.html') { |
|
294 | 294 | $is_site_start = true; |
295 | 295 | } |
296 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
296 | + if ($is_site_start == true && $_POST['reset'] == 'on') { |
|
297 | 297 | $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
298 | 298 | $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
299 | 299 | } |
@@ -302,85 +302,85 @@ discard block |
||
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
305 | +function getFiles($directory, $listing = array(), $count = 0){ |
|
306 | 306 | global $_lang; |
307 | 307 | global $filesfound; |
308 | 308 | $dummy = $count; |
309 | - if($files = scandir($directory)) { |
|
310 | - foreach($files as $file) { |
|
311 | - if($file == '.' || $file == '..') { |
|
309 | + if ($files = scandir($directory)) { |
|
310 | + foreach ($files as $file) { |
|
311 | + if ($file == '.' || $file == '..') { |
|
312 | 312 | continue; |
313 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
313 | + } elseif ($h = @opendir($directory.$file."/")) { |
|
314 | 314 | closedir($h); |
315 | 315 | $count = -1; |
316 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
317 | - } elseif(strpos($file, '.htm') !== false) { |
|
316 | + $listing[$file] = getFiles($directory.$file."/", array(), $count + 1); |
|
317 | + } elseif (strpos($file, '.htm') !== false) { |
|
318 | 318 | $listing[$dummy] = $file; |
319 | 319 | $dummy = $dummy + 1; |
320 | 320 | $filesfound++; |
321 | 321 | } |
322 | 322 | } |
323 | 323 | } else { |
324 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
324 | + echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>"; |
|
325 | 325 | } |
326 | 326 | return ($listing); |
327 | 327 | } |
328 | 328 | |
329 | -function getFileContent($filepath) { |
|
329 | +function getFileContent($filepath){ |
|
330 | 330 | global $_lang; |
331 | 331 | // get the file |
332 | - if(!$buffer = file_get_contents($filepath)) { |
|
333 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
332 | + if (!$buffer = file_get_contents($filepath)) { |
|
333 | + echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>"; |
|
334 | 334 | } else { |
335 | 335 | return $buffer; |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | -function pop_index($array) { |
|
339 | +function pop_index($array){ |
|
340 | 340 | $new_array = array(); |
341 | - foreach($array as $k => $v) { |
|
342 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
341 | + foreach ($array as $k => $v) { |
|
342 | + if ($v !== 'index.html' && $v !== 'index.htm') { |
|
343 | 343 | $new_array[$k] = $v; |
344 | 344 | } else { |
345 | 345 | array_unshift($new_array, $v); |
346 | 346 | } |
347 | 347 | } |
348 | - foreach($array as $k => $v) { |
|
349 | - if(is_array($v)) { |
|
348 | + foreach ($array as $k => $v) { |
|
349 | + if (is_array($v)) { |
|
350 | 350 | $new_array[$k] = $v; |
351 | 351 | } |
352 | 352 | } |
353 | 353 | return $new_array; |
354 | 354 | } |
355 | 355 | |
356 | -function treatContent($src, $filename, $alias) { |
|
356 | +function treatContent($src, $filename, $alias){ |
|
357 | 357 | global $modx; |
358 | 358 | |
359 | 359 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
360 | 360 | |
361 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
361 | + if (preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
362 | 362 | $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
363 | 363 | $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
364 | 364 | } else { |
365 | 365 | $pagetitle = $alias; |
366 | 366 | } |
367 | - if(!$pagetitle) { |
|
367 | + if (!$pagetitle) { |
|
368 | 368 | $pagetitle = $alias; |
369 | 369 | } |
370 | 370 | |
371 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
371 | + if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
372 | 372 | $description = ($matches[1] !== '') ? $matches[1] : $filename; |
373 | 373 | $description = str_replace('[*description*]', '', $description); |
374 | 374 | } else { |
375 | 375 | $description = ''; |
376 | 376 | } |
377 | 377 | |
378 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
378 | + if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
379 | 379 | $content = $matches[1]; |
380 | 380 | } else { |
381 | 381 | $content = $src; |
382 | 382 | $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
383 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
383 | + $r = '$1'.$modx->config['modx_charset'].'$2'; |
|
384 | 384 | $content = preg_replace($s, $r, $content); |
385 | 385 | $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
386 | 386 | } |
@@ -394,38 +394,38 @@ discard block |
||
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
397 | -function convertLink() { |
|
397 | +function convertLink(){ |
|
398 | 398 | global $modx; |
399 | 399 | $tbl_site_content = $modx->getFullTableName('site_content'); |
400 | 400 | |
401 | 401 | $rs = $modx->db->select('id,content', $tbl_site_content); |
402 | - while($row = $modx->db->getRow($rs)) { |
|
402 | + while ($row = $modx->db->getRow($rs)) { |
|
403 | 403 | $id = $row['id']; |
404 | 404 | $array = explode('<a href=', $row['content']); |
405 | 405 | $c = 0; |
406 | - foreach($array as $v) { |
|
407 | - if($v[0] === '"') { |
|
406 | + foreach ($array as $v) { |
|
407 | + if ($v[0] === '"') { |
|
408 | 408 | $v = substr($v, 1); |
409 | 409 | list($href, $v) = explode('"', $v, 2); |
410 | 410 | $_ = $href; |
411 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
412 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
411 | + if (strpos($_, $modx->config['site_url']) !== false) { |
|
412 | + $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_); |
|
413 | 413 | } |
414 | - if($_[0] === '/') { |
|
414 | + if ($_[0] === '/') { |
|
415 | 415 | $_ = substr($_, 1); |
416 | 416 | } |
417 | 417 | $_ = str_replace('/index.html', '.html', $_); |
418 | 418 | $level = substr_count($_, '../'); |
419 | - if(1 < $level) { |
|
420 | - if(!isset($p[$id])) { |
|
419 | + if (1 < $level) { |
|
420 | + if (!isset($p[$id])) { |
|
421 | 421 | $p[$id] = $modx->getParentIds($id); |
422 | 422 | } |
423 | 423 | $k = array_keys($p[$id]); |
424 | - while(0 < $level) { |
|
424 | + while (0 < $level) { |
|
425 | 425 | $dir = array_shift($k); |
426 | 426 | $level--; |
427 | 427 | } |
428 | - if($dir != '') { |
|
428 | + if ($dir != '') { |
|
429 | 429 | $dir .= '/'; |
430 | 430 | } |
431 | 431 | } else { |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | $_ = trim($_, './'); |
436 | - if(strpos($_, '/') !== false) { |
|
436 | + if (strpos($_, '/') !== false) { |
|
437 | 437 | $_ = substr($_, strrpos($_, '/')); |
438 | 438 | } |
439 | - $_ = $dir . str_replace('.html', '', $_); |
|
440 | - if(!isset($target[$_])) { |
|
439 | + $_ = $dir.str_replace('.html', '', $_); |
|
440 | + if (!isset($target[$_])) { |
|
441 | 441 | $target[$_] = $modx->getIdFromAlias($_); |
442 | 442 | } |
443 | 443 | $target[$_] = trim($target[$_]); |
444 | - if(!empty($target[$_])) { |
|
445 | - $href = '[~' . $target[$_] . '~]'; |
|
444 | + if (!empty($target[$_])) { |
|
445 | + $href = '[~'.$target[$_].'~]'; |
|
446 | 446 | } |
447 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
447 | + $array[$c] = '<a href="'.$href.'"'.$v; |
|
448 | 448 | } |
449 | 449 | $c++; |
450 | 450 | } |
@@ -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; |
106 | 107 | |
107 | 108 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -160,7 +161,8 @@ discard block |
||
160 | 161 | return $output; |
161 | 162 | } |
162 | 163 | |
163 | -function importFiles($parent, $filedir, $files, $mode) { |
|
164 | +function importFiles($parent, $filedir, $files, $mode) |
|
165 | +{ |
|
164 | 166 | global $modx; |
165 | 167 | global $_lang, $allowedfiles; |
166 | 168 | global $search_default, $cache_default, $publish_default; |
@@ -302,7 +304,8 @@ discard block |
||
302 | 304 | } |
303 | 305 | } |
304 | 306 | |
305 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
307 | +function getFiles($directory, $listing = array(), $count = 0) |
|
308 | +{ |
|
306 | 309 | global $_lang; |
307 | 310 | global $filesfound; |
308 | 311 | $dummy = $count; |
@@ -326,7 +329,8 @@ discard block |
||
326 | 329 | return ($listing); |
327 | 330 | } |
328 | 331 | |
329 | -function getFileContent($filepath) { |
|
332 | +function getFileContent($filepath) |
|
333 | +{ |
|
330 | 334 | global $_lang; |
331 | 335 | // get the file |
332 | 336 | if(!$buffer = file_get_contents($filepath)) { |
@@ -336,7 +340,8 @@ discard block |
||
336 | 340 | } |
337 | 341 | } |
338 | 342 | |
339 | -function pop_index($array) { |
|
343 | +function pop_index($array) |
|
344 | +{ |
|
340 | 345 | $new_array = array(); |
341 | 346 | foreach($array as $k => $v) { |
342 | 347 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -353,7 +358,8 @@ discard block |
||
353 | 358 | return $new_array; |
354 | 359 | } |
355 | 360 | |
356 | -function treatContent($src, $filename, $alias) { |
|
361 | +function treatContent($src, $filename, $alias) |
|
362 | +{ |
|
357 | 363 | global $modx; |
358 | 364 | |
359 | 365 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -394,7 +400,8 @@ discard block |
||
394 | 400 | ); |
395 | 401 | } |
396 | 402 | |
397 | -function convertLink() { |
|
403 | +function convertLink() |
|
404 | +{ |
|
398 | 405 | global $modx; |
399 | 406 | $tbl_site_content = $modx->getFullTableName('site_content'); |
400 | 407 |
@@ -16,6 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * get_langs_by_key |
18 | 18 | * |
19 | + * @param string $key |
|
19 | 20 | * @return array of languages that define the key in their file |
20 | 21 | */ |
21 | 22 | function get_langs_by_key($key) { |
@@ -36,7 +37,7 @@ discard block |
||
36 | 37 | * |
37 | 38 | * @param string $key specify language key to return options of langauges that override it, default return all languages |
38 | 39 | * @param string $selected_lang specify language to select in option list, default none |
39 | - * @return html option list |
|
40 | + * @return string option list |
|
40 | 41 | */ |
41 | 42 | function get_lang_options($key=null, $selected_lang=null) { |
42 | 43 | global $lang_keys, $_lang; |
@@ -68,12 +68,12 @@ |
||
68 | 68 | $var = ${$name}; |
69 | 69 | $checked = ($var==$value) ? ' checked="checked"' : ''; |
70 | 70 | if($disabled) $disabled = ' disabled'; else $disabled = ''; |
71 | - if($add) $add = ' ' . $add; |
|
72 | - return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
|
71 | + if($add) $add = ' ' . $add; |
|
72 | + return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | function wrap_label($str='',$object) { |
76 | - return "<label>{$object}\n{$str}</label>"; |
|
76 | + return "<label>{$object}\n{$str}</label>"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | function parseText($tpl='', $ph=array()) { |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @return array of keys from a language file |
6 | 6 | */ |
7 | -function get_lang_keys($filename) { |
|
8 | - $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
|
9 | - if(is_file($file) && is_readable($file)) { |
|
7 | +function get_lang_keys($filename){ |
|
8 | + $file = MODX_MANAGER_PATH.'includes/lang'.DIRECTORY_SEPARATOR.$filename; |
|
9 | + if (is_file($file) && is_readable($file)) { |
|
10 | 10 | include($file); |
11 | 11 | return array_keys($_lang); |
12 | 12 | } else { |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array of languages that define the key in their file |
20 | 20 | */ |
21 | -function get_langs_by_key($key) { |
|
21 | +function get_langs_by_key($key){ |
|
22 | 22 | global $lang_keys; |
23 | 23 | $lang_return = array(); |
24 | - foreach($lang_keys as $lang=>$keys) { |
|
25 | - if(in_array($key, $keys)) { |
|
24 | + foreach ($lang_keys as $lang=>$keys) { |
|
25 | + if (in_array($key, $keys)) { |
|
26 | 26 | $lang_return[] = $lang; |
27 | 27 | } |
28 | 28 | } |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @param string $selected_lang specify language to select in option list, default none |
39 | 39 | * @return html option list |
40 | 40 | */ |
41 | -function get_lang_options($key=null, $selected_lang=null) { |
|
41 | +function get_lang_options($key = null, $selected_lang = null){ |
|
42 | 42 | global $lang_keys, $_lang; |
43 | 43 | $lang_options = ''; |
44 | - if($key) { |
|
44 | + if ($key) { |
|
45 | 45 | $languages = get_langs_by_key($key); |
46 | 46 | sort($languages); |
47 | 47 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
48 | 48 | |
49 | - foreach($languages as $language_name) { |
|
49 | + foreach ($languages as $language_name) { |
|
50 | 50 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
51 | 51 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
52 | 52 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } else { |
55 | 55 | $languages = array_keys($lang_keys); |
56 | 56 | sort($languages); |
57 | - foreach($languages as $language_name) { |
|
57 | + foreach ($languages as $language_name) { |
|
58 | 58 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
59 | 59 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
60 | 60 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -63,23 +63,23 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | -function form_radio($name,$value,$add='',$disabled=false) { |
|
66 | +function form_radio($name, $value, $add = '', $disabled = false){ |
|
67 | 67 | global ${$name}; |
68 | 68 | $var = ${$name}; |
69 | - $checked = ($var==$value) ? ' checked="checked"' : ''; |
|
70 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
71 | - if($add) $add = ' ' . $add; |
|
69 | + $checked = ($var == $value) ? ' checked="checked"' : ''; |
|
70 | + if ($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
71 | + if ($add) $add = ' '.$add; |
|
72 | 72 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
73 | 73 | } |
74 | 74 | |
75 | -function wrap_label($str='',$object) { |
|
75 | +function wrap_label($str = '', $object){ |
|
76 | 76 | return "<label>{$object}\n{$str}</label>"; |
77 | 77 | } |
78 | 78 | |
79 | -function parseText($tpl='', $ph=array()) { |
|
80 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
79 | +function parseText($tpl = '', $ph = array()){ |
|
80 | + if (empty($ph) || empty($tpl)) return $tpl; |
|
81 | 81 | |
82 | - foreach($ph as $k=>$v) |
|
82 | + foreach ($ph as $k=>$v) |
|
83 | 83 | { |
84 | 84 | $k = "[+{$k}+]"; |
85 | 85 | $tpl = str_replace($k, $v, $tpl); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | return $tpl; |
88 | 88 | } |
89 | 89 | |
90 | -function showHide($cond=true) { |
|
90 | +function showHide($cond = true){ |
|
91 | 91 | global $displayStyle; |
92 | 92 | $showHide = $cond ? $displayStyle : 'none'; |
93 | 93 | return sprintf('style="display:%s"', $showHide); |
@@ -4,12 +4,13 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @return array of keys from a language file |
6 | 6 | */ |
7 | -function get_lang_keys($filename) { |
|
7 | +function get_lang_keys($filename) |
|
8 | +{ |
|
8 | 9 | $file = MODX_MANAGER_PATH.'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
9 | - if(is_file($file) && is_readable($file)) { |
|
10 | + if(is_file($file) && is_readable($file)) { |
|
10 | 11 | include($file); |
11 | 12 | return array_keys($_lang); |
12 | - } else { |
|
13 | + } else { |
|
13 | 14 | return array(); |
14 | 15 | } |
15 | 16 | } |
@@ -18,11 +19,12 @@ discard block |
||
18 | 19 | * |
19 | 20 | * @return array of languages that define the key in their file |
20 | 21 | */ |
21 | -function get_langs_by_key($key) { |
|
22 | +function get_langs_by_key($key) |
|
23 | +{ |
|
22 | 24 | global $lang_keys; |
23 | 25 | $lang_return = array(); |
24 | - foreach($lang_keys as $lang=>$keys) { |
|
25 | - if(in_array($key, $keys)) { |
|
26 | + foreach($lang_keys as $lang=>$keys) { |
|
27 | + if(in_array($key, $keys)) { |
|
26 | 28 | $lang_return[] = $lang; |
27 | 29 | } |
28 | 30 | } |
@@ -38,23 +40,24 @@ discard block |
||
38 | 40 | * @param string $selected_lang specify language to select in option list, default none |
39 | 41 | * @return html option list |
40 | 42 | */ |
41 | -function get_lang_options($key=null, $selected_lang=null) { |
|
43 | +function get_lang_options($key=null, $selected_lang=null) |
|
44 | +{ |
|
42 | 45 | global $lang_keys, $_lang; |
43 | 46 | $lang_options = ''; |
44 | - if($key) { |
|
47 | + if($key) { |
|
45 | 48 | $languages = get_langs_by_key($key); |
46 | 49 | sort($languages); |
47 | 50 | $lang_options .= '<option value="">'.$_lang['language_title'].'</option>'; |
48 | 51 | |
49 | - foreach($languages as $language_name) { |
|
52 | + foreach($languages as $language_name) { |
|
50 | 53 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
51 | 54 | $lang_options .= '<option value="'.$language_name.'">'.$uclanguage_name.'</option>'; |
52 | 55 | } |
53 | 56 | return $lang_options; |
54 | - } else { |
|
57 | + } else { |
|
55 | 58 | $languages = array_keys($lang_keys); |
56 | 59 | sort($languages); |
57 | - foreach($languages as $language_name) { |
|
60 | + foreach($languages as $language_name) { |
|
58 | 61 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name)); |
59 | 62 | $sel = $language_name == $selected_lang ? ' selected="selected"' : ''; |
60 | 63 | $lang_options .= '<option value="'.$language_name.'" '.$sel.'>'.$uclanguage_name.'</option>'; |
@@ -63,31 +66,42 @@ discard block |
||
63 | 66 | } |
64 | 67 | } |
65 | 68 | |
66 | -function form_radio($name,$value,$add='',$disabled=false) { |
|
69 | +function form_radio($name,$value,$add='',$disabled=false) |
|
70 | +{ |
|
67 | 71 | global ${$name}; |
68 | 72 | $var = ${$name}; |
69 | 73 | $checked = ($var==$value) ? ' checked="checked"' : ''; |
70 | - if($disabled) $disabled = ' disabled'; else $disabled = ''; |
|
71 | - if($add) $add = ' ' . $add; |
|
74 | + if($disabled) { |
|
75 | + $disabled = ' disabled'; |
|
76 | + } else { |
|
77 | + $disabled = ''; |
|
78 | + } |
|
79 | + if($add) { |
|
80 | + $add = ' ' . $add; |
|
81 | + } |
|
72 | 82 | return sprintf('<input onchange="documentDirty=true;" type="radio" name="%s" value="%s" %s %s %s />', $name, $value, $checked, $disabled, $add); |
73 | 83 | } |
74 | 84 | |
75 | -function wrap_label($str='',$object) { |
|
85 | +function wrap_label($str='',$object) |
|
86 | +{ |
|
76 | 87 | return "<label>{$object}\n{$str}</label>"; |
77 | 88 | } |
78 | 89 | |
79 | -function parseText($tpl='', $ph=array()) { |
|
80 | - if(empty($ph) || empty($tpl)) return $tpl; |
|
90 | +function parseText($tpl='', $ph=array()) |
|
91 | +{ |
|
92 | + if(empty($ph) || empty($tpl)) { |
|
93 | + return $tpl; |
|
94 | + } |
|
81 | 95 | |
82 | - foreach($ph as $k=>$v) |
|
83 | - { |
|
96 | + foreach($ph as $k=>$v) { |
|
84 | 97 | $k = "[+{$k}+]"; |
85 | 98 | $tpl = str_replace($k, $v, $tpl); |
86 | 99 | } |
87 | 100 | return $tpl; |
88 | 101 | } |
89 | 102 | |
90 | -function showHide($cond=true) { |
|
103 | +function showHide($cond=true) |
|
104 | +{ |
|
91 | 105 | global $displayStyle; |
92 | 106 | $showHide = $cond ? $displayStyle : 'none'; |
93 | 107 | return sprintf('style="display:%s"', $showHide); |
@@ -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 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(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(IN_MANAGER_MODE != 'true') { |
|
2 | +if (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 | } |
@@ -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>'); |
@@ -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) { |