@@ -170,70 +170,70 @@ |
||
| 170 | 170 | array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false |
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | - if (intval($params['shareparams']) || !empty($params['dependencies'])) { |
|
| 174 | - $dependencies = explode(',', $params['dependencies']); |
|
| 175 | - foreach ($dependencies as $dependency) { |
|
| 176 | - $dependency = explode(':', $dependency); |
|
| 177 | - switch (trim($dependency[0])) { |
|
| 178 | - case 'template': |
|
| 179 | - $mdp[] = array( |
|
| 180 | - 'module' => $params['name'], |
|
| 181 | - 'table' => 'templates', |
|
| 182 | - 'column' => 'templatename', |
|
| 183 | - 'type' => 50, |
|
| 184 | - 'name' => trim($dependency[1]) |
|
| 185 | - ); |
|
| 186 | - break; |
|
| 187 | - case 'tv': |
|
| 188 | - case 'tmplvar': |
|
| 189 | - $mdp[] = array( |
|
| 190 | - 'module' => $params['name'], |
|
| 191 | - 'table' => 'tmplvars', |
|
| 192 | - 'column' => 'name', |
|
| 193 | - 'type' => 60, |
|
| 194 | - 'name' => trim($dependency[1]) |
|
| 195 | - ); |
|
| 196 | - break; |
|
| 197 | - case 'chunk': |
|
| 198 | - case 'htmlsnippet': |
|
| 199 | - $mdp[] = array( |
|
| 200 | - 'module' => $params['name'], |
|
| 201 | - 'table' => 'htmlsnippets', |
|
| 202 | - 'column' => 'name', |
|
| 203 | - 'type' => 10, |
|
| 204 | - 'name' => trim($dependency[1]) |
|
| 205 | - ); |
|
| 206 | - break; |
|
| 207 | - case 'snippet': |
|
| 208 | - $mdp[] = array( |
|
| 209 | - 'module' => $params['name'], |
|
| 210 | - 'table' => 'snippets', |
|
| 211 | - 'column' => 'name', |
|
| 212 | - 'type' => 40, |
|
| 213 | - 'name' => trim($dependency[1]) |
|
| 214 | - ); |
|
| 215 | - break; |
|
| 216 | - case 'plugin': |
|
| 217 | - $mdp[] = array( |
|
| 218 | - 'module' => $params['name'], |
|
| 219 | - 'table' => 'plugins', |
|
| 220 | - 'column' => 'name', |
|
| 221 | - 'type' => 30, |
|
| 222 | - 'name' => trim($dependency[1]) |
|
| 223 | - ); |
|
| 224 | - break; |
|
| 225 | - case 'resource': |
|
| 226 | - $mdp[] = array( |
|
| 227 | - 'module' => $params['name'], |
|
| 228 | - 'table' => 'content', |
|
| 229 | - 'column' => 'pagetitle', |
|
| 230 | - 'type' => 20, |
|
| 231 | - 'name' => trim($dependency[1]) |
|
| 232 | - ); |
|
| 233 | - break; |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 173 | + if (intval($params['shareparams']) || !empty($params['dependencies'])) { |
|
| 174 | + $dependencies = explode(',', $params['dependencies']); |
|
| 175 | + foreach ($dependencies as $dependency) { |
|
| 176 | + $dependency = explode(':', $dependency); |
|
| 177 | + switch (trim($dependency[0])) { |
|
| 178 | + case 'template': |
|
| 179 | + $mdp[] = array( |
|
| 180 | + 'module' => $params['name'], |
|
| 181 | + 'table' => 'templates', |
|
| 182 | + 'column' => 'templatename', |
|
| 183 | + 'type' => 50, |
|
| 184 | + 'name' => trim($dependency[1]) |
|
| 185 | + ); |
|
| 186 | + break; |
|
| 187 | + case 'tv': |
|
| 188 | + case 'tmplvar': |
|
| 189 | + $mdp[] = array( |
|
| 190 | + 'module' => $params['name'], |
|
| 191 | + 'table' => 'tmplvars', |
|
| 192 | + 'column' => 'name', |
|
| 193 | + 'type' => 60, |
|
| 194 | + 'name' => trim($dependency[1]) |
|
| 195 | + ); |
|
| 196 | + break; |
|
| 197 | + case 'chunk': |
|
| 198 | + case 'htmlsnippet': |
|
| 199 | + $mdp[] = array( |
|
| 200 | + 'module' => $params['name'], |
|
| 201 | + 'table' => 'htmlsnippets', |
|
| 202 | + 'column' => 'name', |
|
| 203 | + 'type' => 10, |
|
| 204 | + 'name' => trim($dependency[1]) |
|
| 205 | + ); |
|
| 206 | + break; |
|
| 207 | + case 'snippet': |
|
| 208 | + $mdp[] = array( |
|
| 209 | + 'module' => $params['name'], |
|
| 210 | + 'table' => 'snippets', |
|
| 211 | + 'column' => 'name', |
|
| 212 | + 'type' => 40, |
|
| 213 | + 'name' => trim($dependency[1]) |
|
| 214 | + ); |
|
| 215 | + break; |
|
| 216 | + case 'plugin': |
|
| 217 | + $mdp[] = array( |
|
| 218 | + 'module' => $params['name'], |
|
| 219 | + 'table' => 'plugins', |
|
| 220 | + 'column' => 'name', |
|
| 221 | + 'type' => 30, |
|
| 222 | + 'name' => trim($dependency[1]) |
|
| 223 | + ); |
|
| 224 | + break; |
|
| 225 | + case 'resource': |
|
| 226 | + $mdp[] = array( |
|
| 227 | + 'module' => $params['name'], |
|
| 228 | + 'table' => 'content', |
|
| 229 | + 'column' => 'pagetitle', |
|
| 230 | + 'type' => 20, |
|
| 231 | + 'name' => trim($dependency[1]) |
|
| 232 | + ); |
|
| 233 | + break; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | $d->close(); |
| 239 | 239 | } |
@@ -4,7 +4,9 @@ discard block |
||
| 4 | 4 | if (is_file($base_path . 'assets/cache/siteManager.php')) { |
| 5 | 5 | include_once($base_path . 'assets/cache/siteManager.php'); |
| 6 | 6 | } |
| 7 | -if(!defined('MGR_DIR')) define('MGR_DIR', 'manager'); |
|
| 7 | +if(!defined('MGR_DIR')) { |
|
| 8 | + define('MGR_DIR', 'manager'); |
|
| 9 | +} |
|
| 8 | 10 | |
| 9 | 11 | require_once('../'.MGR_DIR.'/includes/version.inc.php'); |
| 10 | 12 | |
@@ -19,12 +21,12 @@ discard block |
||
| 19 | 21 | $mt = &$moduleTemplates; |
| 20 | 22 | if(is_dir($templatePath) && is_readable($templatePath)) { |
| 21 | 23 | $d = dir($templatePath); |
| 22 | - while (false !== ($tplfile = $d->read())) |
|
| 23 | - { |
|
| 24 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 24 | + while (false !== ($tplfile = $d->read())) { |
|
| 25 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 25 | 28 | $params = parse_docblock($templatePath, $tplfile); |
| 26 | - if(is_array($params) && (count($params)>0)) |
|
| 27 | - { |
|
| 29 | + if(is_array($params) && (count($params)>0)) { |
|
| 28 | 30 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
| 29 | 31 | $mt[] = array |
| 30 | 32 | ( |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | if(is_dir($tvPath) && is_readable($tvPath)) { |
| 49 | 51 | $d = dir($tvPath); |
| 50 | 52 | while (false !== ($tplfile = $d->read())) { |
| 51 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
| 53 | + if(substr($tplfile, -4) != '.tpl') { |
|
| 54 | + continue; |
|
| 55 | + } |
|
| 52 | 56 | $params = parse_docblock($tvPath, $tplfile); |
| 53 | 57 | if(is_array($params) && (count($params)>0)) { |
| 54 | 58 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
@@ -241,7 +245,8 @@ discard block |
||
| 241 | 245 | // setup callback function |
| 242 | 246 | $callBackFnc = "clean_up"; |
| 243 | 247 | |
| 244 | -function clean_up($sqlParser) { |
|
| 248 | +function clean_up($sqlParser) |
|
| 249 | +{ |
|
| 245 | 250 | $ids = array(); |
| 246 | 251 | |
| 247 | 252 | // secure web documents - privateweb |
@@ -254,9 +259,10 @@ discard block |
||
| 254 | 259 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 255 | 260 | if(!$ds) { |
| 256 | 261 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 257 | - } |
|
| 258 | - else { |
|
| 259 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 262 | + } else { |
|
| 263 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 264 | + $ids[]=$r["id"]; |
|
| 265 | + } |
|
| 260 | 266 | if(count($ids)>0) { |
| 261 | 267 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 262 | 268 | unset($ids); |
@@ -273,9 +279,10 @@ discard block |
||
| 273 | 279 | $ds = mysqli_query($sqlParser->conn,$sql); |
| 274 | 280 | if(!$ds) { |
| 275 | 281 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
| 276 | - } |
|
| 277 | - else { |
|
| 278 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
| 282 | + } else { |
|
| 283 | + while($r = mysqli_fetch_assoc($ds)) { |
|
| 284 | + $ids[]=$r["id"]; |
|
| 285 | + } |
|
| 279 | 286 | if(count($ids)>0) { |
| 280 | 287 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
| 281 | 288 | unset($ids); |
@@ -283,7 +290,8 @@ discard block |
||
| 283 | 290 | } |
| 284 | 291 | } |
| 285 | 292 | |
| 286 | -function parse_docblock($element_dir, $filename) { |
|
| 293 | +function parse_docblock($element_dir, $filename) |
|
| 294 | +{ |
|
| 287 | 295 | $params = array(); |
| 288 | 296 | $fullpath = $element_dir . '/' . $filename; |
| 289 | 297 | if(is_readable($fullpath)) { |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | <form name="install" id="install_form" action="index.php?action=options" method="post"> |
| 21 | 21 | <?php |
| 22 | 22 | if ($errors == 0) { |
| 23 | - // check if install folder is removeable |
|
| 23 | + // check if install folder is removeable |
|
| 24 | 24 | if (is_writable("../install")) { ?> |
| 25 | 25 | <span id="removeinstall" style="float:left;cursor:pointer;color:#505050;line-height:18px;" onclick="var chk=document.install.rminstaller; if(chk) chk.checked=!chk.checked;"><input type="checkbox" name="rminstaller" onclick="event.cancelBubble=true;" <?php echo (empty ($errors) ? 'checked="checked"' : '') ?> style="cursor:default;" /><?php echo $_lang['remove_install_folder_auto'] ?></span> |
| 26 | 26 | <?php |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | $self = 'install/connection.databasetest.php'; |
| 9 | 9 | $base_path = str_replace($self,'',str_replace('\\','/', __FILE__)); |
| 10 | 10 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 11 | - include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 11 | + include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 12 | 12 | } |
| 13 | 13 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
| 14 | - define('MGR_DIR','manager'); |
|
| 14 | + define('MGR_DIR','manager'); |
|
| 15 | 15 | } |
| 16 | 16 | require_once("lang.php"); |
| 17 | 17 | |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | $output = $_lang["status_checking_database"]; |
| 19 | 19 | if (!$conn = mysqli_connect($host, $uid, $pwd)) { |
| 20 | 20 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed'].'</span>'; |
| 21 | -} |
|
| 22 | -else { |
|
| 21 | +} else { |
|
| 23 | 22 | $database_name = mysqli_real_escape_string($conn, $_POST['database_name']); |
| 24 | 23 | $database_name = str_replace("`", "", $database_name); |
| 25 | 24 | $tableprefix = mysqli_real_escape_string($conn, $_POST['tableprefix']); |
@@ -31,20 +30,16 @@ discard block |
||
| 31 | 30 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 32 | 31 | $query = "CREATE DATABASE `".$database_name."` CHARACTER SET ".$database_charset." COLLATE ".$database_collation.";"; |
| 33 | 32 | |
| 34 | - if (! mysqli_query($conn, $query)){ |
|
| 33 | + if (! mysqli_query($conn, $query)) { |
|
| 35 | 34 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_could_not_create_database'].'</span>'; |
| 36 | - } |
|
| 37 | - else { |
|
| 35 | + } else { |
|
| 38 | 36 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed_database_created'].'</span>'; |
| 39 | 37 | } |
| 40 | - } |
|
| 41 | - elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 38 | + } elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { |
|
| 42 | 39 | $output .= '<span id="database_fail" style="color:#FF0000;">'.$_lang['status_failed_table_prefix_already_in_use'].'</span>'; |
| 43 | - } |
|
| 44 | - elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 40 | + } elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { |
|
| 45 | 41 | $output .= '<span id="database_fail" style="color:#FF0000;">'.sprintf($_lang['status_failed_database_collation_does_not_match'], $row[1]).'</span>'; |
| 46 | - } |
|
| 47 | - else { |
|
| 42 | + } else { |
|
| 48 | 43 | $output .= '<span id="database_pass" style="color:#80c000;">'.$_lang['status_passed'].'</span>'; |
| 49 | 44 | } |
| 50 | 45 | } |
@@ -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; |
@@ -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,88 +27,88 @@ 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 | } |
| 113 | 113 | |
| 114 | 114 | function getLangs($install_language) |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | sort($langs); |
| 132 | 132 | |
| 133 | 133 | $_ = array(); |
| 134 | - foreach ($langs as $language) { |
|
| 134 | + foreach ($langs as $language) { |
|
| 135 | 135 | $abrv_language = explode('.', $language); |
| 136 | 136 | $selected = (strtolower($abrv_language[0]) == strtolower($manager_language)) ? ' selected' : ''; |
| 137 | 137 | $_[] = sprintf('<option value="%s" %s>%s</option>', $abrv_language[0], $selected, |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | $self = 'install/connection.collation.php'; |
| 8 | 8 | $base_path = str_replace($self,'',str_replace('\\','/', __FILE__)); |
| 9 | 9 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 10 | - include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 10 | + include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 11 | 11 | } |
| 12 | 12 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
| 13 | - define('MGR_DIR','manager'); |
|
| 13 | + define('MGR_DIR','manager'); |
|
| 14 | 14 | } |
| 15 | 15 | require_once('lang.php'); |
| 16 | 16 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | $rs = array('recommend'=>''); |
| 60 | 60 | $order = explode(',', $order); |
| 61 | 61 | foreach($order as $v) { |
| 62 | - foreach($array as $name=>$sel) { |
|
| 63 | - if(strpos($name,$v)!==false) { |
|
| 64 | - $rs[$name] = $array[$name]; |
|
| 65 | - unset($array[$name]); |
|
| 66 | - } |
|
| 67 | - } |
|
| 62 | + foreach($array as $name=>$sel) { |
|
| 63 | + if(strpos($name,$v)!==false) { |
|
| 64 | + $rs[$name] = $array[$name]; |
|
| 65 | + unset($array[$name]); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | $rs['unrecommend']=''; |
| 70 | 70 | return $rs + $array; |
@@ -14,11 +14,12 @@ discard block |
||
| 14 | 14 | } |
| 15 | 15 | require_once('lang.php'); |
| 16 | 16 | |
| 17 | -if(function_exists('mysqli_connect')) { |
|
| 17 | +if(function_exists('mysqli_connect')) { |
|
| 18 | 18 | $conn = mysqli_connect($host, $uid, $pwd); |
| 19 | - if(!$conn) exit('can not connect'); |
|
| 20 | -} |
|
| 21 | -else { |
|
| 19 | + if(!$conn) { |
|
| 20 | + exit('can not connect'); |
|
| 21 | + } |
|
| 22 | + } else { |
|
| 22 | 23 | exit('undefined function mysqli_connect()'); |
| 23 | 24 | } |
| 24 | 25 | |
@@ -34,23 +35,31 @@ discard block |
||
| 34 | 35 | $database_collation = htmlentities($_POST['database_collation']); |
| 35 | 36 | $recommend_collation = $_lang['recommend_collation']; |
| 36 | 37 | |
| 37 | - if (isset($_[$recommend_collation])) $_[$recommend_collation] = ' selected'; |
|
| 38 | - elseif(isset($_['utf8mb4_general_ci'])) $_['utf8mb4_general_ci'] = ' selected'; |
|
| 39 | - elseif(isset($_['utf8_general_ci'])) $_['utf8_general_ci'] = ' selected'; |
|
| 40 | - elseif(isset($_[$database_collation])) $_[$database_collation] = ' selected'; |
|
| 38 | + if (isset($_[$recommend_collation])) { |
|
| 39 | + $_[$recommend_collation] = ' selected'; |
|
| 40 | + } elseif(isset($_['utf8mb4_general_ci'])) { |
|
| 41 | + $_['utf8mb4_general_ci'] = ' selected'; |
|
| 42 | + } elseif(isset($_['utf8_general_ci'])) { |
|
| 43 | + $_['utf8_general_ci'] = ' selected'; |
|
| 44 | + } elseif(isset($_[$database_collation])) { |
|
| 45 | + $_[$database_collation] = ' selected'; |
|
| 46 | + } |
|
| 41 | 47 | |
| 42 | 48 | $_ = sortItem($_,$_lang['recommend_collations_order']); |
| 43 | 49 | |
| 44 | 50 | foreach($_ as $collation=>$selected) { |
| 45 | 51 | $collation = htmlentities($collation); |
| 46 | 52 | // if(substr($collation,0,4)!=='utf8') continue; |
| 47 | - if(strpos($collation,'sjis')===0) continue; |
|
| 48 | - if($collation=='recommend') |
|
| 49 | - $output .= '<optgroup label="recommend">'; |
|
| 50 | - elseif($collation=='unrecommend') |
|
| 51 | - $output .= '</optgroup><optgroup label="unrecommend">'; |
|
| 52 | - else |
|
| 53 | - $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
|
| 53 | + if(strpos($collation,'sjis')===0) { |
|
| 54 | + continue; |
|
| 55 | + } |
|
| 56 | + if($collation=='recommend') { |
|
| 57 | + $output .= '<optgroup label="recommend">'; |
|
| 58 | + } elseif($collation=='unrecommend') { |
|
| 59 | + $output .= '</optgroup><optgroup label="unrecommend">'; |
|
| 60 | + } else { |
|
| 61 | + $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
|
| 62 | + } |
|
| 54 | 63 | } |
| 55 | 64 | $output .= '</optgroup></select>'; |
| 56 | 65 | } |
@@ -60,7 +69,8 @@ discard block |
||
| 60 | 69 | |
| 61 | 70 | |
| 62 | 71 | |
| 63 | -function sortItem($array=array(),$order='utf8mb4,utf8') { |
|
| 72 | +function sortItem($array=array(),$order='utf8mb4,utf8') |
|
| 73 | +{ |
|
| 64 | 74 | $rs = array('recommend'=>''); |
| 65 | 75 | $order = explode(',', $order); |
| 66 | 76 | foreach($order as $v) { |
@@ -16,10 +16,10 @@ |
||
| 16 | 16 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); |
| 17 | 17 | |
| 18 | 18 | if (is_file("{$base_path}assets/cache/siteManager.php")) { |
| 19 | - include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 19 | + include_once("{$base_path}assets/cache/siteManager.php"); |
|
| 20 | 20 | } |
| 21 | 21 | if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) { |
| 22 | - define('MGR_DIR', 'manager'); |
|
| 22 | + define('MGR_DIR', 'manager'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -478,7 +478,8 @@ discard block |
||
| 478 | 478 | return s; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 481 | + <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { |
|
| 482 | +// Web Link specific ?> |
|
| 482 | 483 | var lastImageCtrl; |
| 483 | 484 | var lastFileCtrl; |
| 484 | 485 | |
@@ -694,7 +695,8 @@ discard block |
||
| 694 | 695 | </td> |
| 695 | 696 | </tr> |
| 696 | 697 | |
| 697 | - <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 698 | + <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { |
|
| 699 | +// Web Link specific ?> |
|
| 698 | 700 | |
| 699 | 701 | <tr> |
| 700 | 702 | <td><span class="warning"><?= $_lang['weblink'] ?></span> |
@@ -1356,7 +1358,9 @@ discard block |
||
| 1356 | 1358 | if($documentId > 0) { |
| 1357 | 1359 | // Load up, the permissions from the parent (if new document) or existing document |
| 1358 | 1360 | $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
| 1359 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1361 | + while($currentgroup = $modx->db->getRow($rs)) { |
|
| 1362 | + $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1363 | + } |
|
| 1360 | 1364 | |
| 1361 | 1365 | // Load up the current permissions and names |
| 1362 | 1366 | $vs = array( |
@@ -1418,7 +1422,9 @@ discard block |
||
| 1418 | 1422 | |
| 1419 | 1423 | // Create attribute string list |
| 1420 | 1424 | $inputString = array(); |
| 1421 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1425 | + foreach($inputAttributes as $k => $v) { |
|
| 1426 | + $inputString[] = $k . '="' . $v . '"'; |
|
| 1427 | + } |
|
| 1422 | 1428 | |
| 1423 | 1429 | // Make the <input> HTML |
| 1424 | 1430 | $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
@@ -1535,7 +1541,8 @@ discard block |
||
| 1535 | 1541 | } |
| 1536 | 1542 | } |
| 1537 | 1543 | |
| 1538 | -function getDefaultTemplate() { |
|
| 1544 | +function getDefaultTemplate() |
|
| 1545 | +{ |
|
| 1539 | 1546 | global $modx; |
| 1540 | 1547 | |
| 1541 | 1548 | switch($modx->config['auto_template_logic']) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /********************/ |
@@ -12,30 +12,30 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // check permissions |
| 14 | 14 | switch($modx->manager->action) { |
| 15 | - case 27: |
|
| 16 | - if(!$modx->hasPermission('edit_document')) { |
|
| 17 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 18 | - } |
|
| 19 | - break; |
|
| 20 | - case 85: |
|
| 21 | - case 72: |
|
| 22 | - case 4: |
|
| 23 | - if(!$modx->hasPermission('new_document')) { |
|
| 24 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 25 | - } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | - // check user has permissions for parent |
|
| 27 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 28 | - $udperms = new udperms(); |
|
| 29 | - $udperms->user = $modx->getLoginUserID(); |
|
| 30 | - $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
|
| 31 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 32 | - if(!$udperms->checkPermissions()) { |
|
| 33 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - break; |
|
| 37 | - default: |
|
| 38 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 15 | + case 27: |
|
| 16 | + if(!$modx->hasPermission('edit_document')) { |
|
| 17 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 18 | + } |
|
| 19 | + break; |
|
| 20 | + case 85: |
|
| 21 | + case 72: |
|
| 22 | + case 4: |
|
| 23 | + if(!$modx->hasPermission('new_document')) { |
|
| 24 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 25 | + } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | + // check user has permissions for parent |
|
| 27 | + include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 28 | + $udperms = new udperms(); |
|
| 29 | + $udperms->user = $modx->getLoginUserID(); |
|
| 30 | + $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
|
| 31 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 32 | + if(!$udperms->checkPermissions()) { |
|
| 33 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + break; |
|
| 37 | + default: |
|
| 38 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars'); |
| 55 | 55 | |
| 56 | 56 | if($modx->manager->action == 27) { |
| 57 | - //editing an existing document |
|
| 58 | - // check permissions on the document |
|
| 59 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 60 | - $udperms = new udperms(); |
|
| 61 | - $udperms->user = $modx->getLoginUserID(); |
|
| 62 | - $udperms->document = $id; |
|
| 63 | - $udperms->role = $_SESSION['mgrRole']; |
|
| 64 | - |
|
| 65 | - if(!$udperms->checkPermissions()) { |
|
| 66 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 67 | - } |
|
| 57 | + //editing an existing document |
|
| 58 | + // check permissions on the document |
|
| 59 | + include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 60 | + $udperms = new udperms(); |
|
| 61 | + $udperms->user = $modx->getLoginUserID(); |
|
| 62 | + $udperms->document = $id; |
|
| 63 | + $udperms->role = $_SESSION['mgrRole']; |
|
| 64 | + |
|
| 65 | + if(!$udperms->checkPermissions()) { |
|
| 66 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // check to see if resource isn't locked |
| 71 | 71 | if($lockedEl = $modx->elementIsLocked(7, $id)) { |
| 72 | - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
|
| 72 | + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
|
| 73 | 73 | } |
| 74 | 74 | // end check for lock |
| 75 | 75 | |
@@ -78,74 +78,74 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // get document groups for current user |
| 80 | 80 | if($_SESSION['mgrDocgroups']) { |
| 81 | - $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
|
| 81 | + $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if(!empty ($id)) { |
| 85 | - $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
|
| 86 | - if($docgrp) { |
|
| 87 | - $access .= " OR dg.document_group IN ({$docgrp})"; |
|
| 88 | - } |
|
| 89 | - $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
|
| 90 | - $content = array(); |
|
| 91 | - $content = $modx->db->getRow($rs); |
|
| 92 | - $modx->documentObject = &$content; |
|
| 93 | - if(!$content) { |
|
| 94 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 95 | - } |
|
| 96 | - $_SESSION['itemname'] = $content['pagetitle']; |
|
| 85 | + $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
|
| 86 | + if($docgrp) { |
|
| 87 | + $access .= " OR dg.document_group IN ({$docgrp})"; |
|
| 88 | + } |
|
| 89 | + $rs = $modx->db->select('sc.*', "{$tbl_site_content} AS sc LEFT JOIN {$tbl_document_groups} AS dg ON dg.document=sc.id", "sc.id='{$id}' AND ({$access})"); |
|
| 90 | + $content = array(); |
|
| 91 | + $content = $modx->db->getRow($rs); |
|
| 92 | + $modx->documentObject = &$content; |
|
| 93 | + if(!$content) { |
|
| 94 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 95 | + } |
|
| 96 | + $_SESSION['itemname'] = $content['pagetitle']; |
|
| 97 | 97 | } else { |
| 98 | - $content = array(); |
|
| 98 | + $content = array(); |
|
| 99 | 99 | |
| 100 | - if(isset($_REQUEST['newtemplate'])) { |
|
| 101 | - $content['template'] = $_REQUEST['newtemplate']; |
|
| 102 | - } else { |
|
| 103 | - $content['template'] = getDefaultTemplate(); |
|
| 104 | - } |
|
| 100 | + if(isset($_REQUEST['newtemplate'])) { |
|
| 101 | + $content['template'] = $_REQUEST['newtemplate']; |
|
| 102 | + } else { |
|
| 103 | + $content['template'] = getDefaultTemplate(); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $_SESSION['itemname'] = $_lang["new_resource"]; |
|
| 106 | + $_SESSION['itemname'] = $_lang["new_resource"]; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // restore saved form |
| 110 | 110 | $formRestored = $modx->manager->loadFormValues(); |
| 111 | 111 | if(isset($_REQUEST['newtemplate'])) { |
| 112 | - $formRestored = true; |
|
| 112 | + $formRestored = true; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // retain form values if template was changed |
| 116 | 116 | // edited to convert pub_date and unpub_date |
| 117 | 117 | // sottwell 02-09-2006 |
| 118 | 118 | if($formRestored == true) { |
| 119 | - $content = array_merge($content, $_POST); |
|
| 120 | - $content['content'] = $_POST['ta']; |
|
| 121 | - if(empty ($content['pub_date'])) { |
|
| 122 | - unset ($content['pub_date']); |
|
| 123 | - } else { |
|
| 124 | - $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
|
| 125 | - } |
|
| 126 | - if(empty ($content['unpub_date'])) { |
|
| 127 | - unset ($content['unpub_date']); |
|
| 128 | - } else { |
|
| 129 | - $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
|
| 130 | - } |
|
| 119 | + $content = array_merge($content, $_POST); |
|
| 120 | + $content['content'] = $_POST['ta']; |
|
| 121 | + if(empty ($content['pub_date'])) { |
|
| 122 | + unset ($content['pub_date']); |
|
| 123 | + } else { |
|
| 124 | + $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
|
| 125 | + } |
|
| 126 | + if(empty ($content['unpub_date'])) { |
|
| 127 | + unset ($content['unpub_date']); |
|
| 128 | + } else { |
|
| 129 | + $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // increase menu index if this is a new document |
| 134 | 134 | if(!isset ($_REQUEST['id'])) { |
| 135 | - if(!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | - $modx->config['auto_menuindex'] = 1; |
|
| 137 | - } |
|
| 138 | - if($modx->config['auto_menuindex']) { |
|
| 139 | - $pid = intval($_REQUEST['pid']); |
|
| 140 | - $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
|
| 141 | - $content['menuindex'] = $modx->db->getValue($rs); |
|
| 142 | - } else { |
|
| 143 | - $content['menuindex'] = 0; |
|
| 144 | - } |
|
| 135 | + if(!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | + $modx->config['auto_menuindex'] = 1; |
|
| 137 | + } |
|
| 138 | + if($modx->config['auto_menuindex']) { |
|
| 139 | + $pid = intval($_REQUEST['pid']); |
|
| 140 | + $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
|
| 141 | + $content['menuindex'] = $modx->db->getValue($rs); |
|
| 142 | + } else { |
|
| 143 | + $content['menuindex'] = 0; |
|
| 144 | + } |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if(isset ($_POST['which_editor'])) { |
| 148 | - $modx->config['which_editor'] = $_POST['which_editor']; |
|
| 148 | + $modx->config['which_editor'] = $_POST['which_editor']; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Add lock-element JS-Script |
@@ -545,23 +545,23 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | <form name="mutate" id="mutate" class="content" method="post" enctype="multipart/form-data" action="index.php" onsubmit="documentDirty=false;"> |
| 547 | 547 | <?php |
| 548 | - // invoke OnDocFormPrerender event |
|
| 549 | - $evtOut = $modx->invokeEvent('OnDocFormPrerender', array( |
|
| 550 | - 'id' => $id, |
|
| 551 | - 'template' => $content['template'] |
|
| 552 | - )); |
|
| 553 | - |
|
| 554 | - if(is_array($evtOut)) { |
|
| 555 | - echo implode('', $evtOut); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - /*************************/ |
|
| 559 | - $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; |
|
| 560 | - $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon'; |
|
| 561 | - $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : ''; |
|
| 562 | - /*************************/ |
|
| 563 | - |
|
| 564 | - ?> |
|
| 548 | + // invoke OnDocFormPrerender event |
|
| 549 | + $evtOut = $modx->invokeEvent('OnDocFormPrerender', array( |
|
| 550 | + 'id' => $id, |
|
| 551 | + 'template' => $content['template'] |
|
| 552 | + )); |
|
| 553 | + |
|
| 554 | + if(is_array($evtOut)) { |
|
| 555 | + echo implode('', $evtOut); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + /*************************/ |
|
| 559 | + $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; |
|
| 560 | + $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon'; |
|
| 561 | + $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : ''; |
|
| 562 | + /*************************/ |
|
| 563 | + |
|
| 564 | + ?> |
|
| 565 | 565 | <input type="hidden" name="a" value="5" /> |
| 566 | 566 | <input type="hidden" name="id" value="<?= $content['id'] ?>" /> |
| 567 | 567 | <input type="hidden" name="mode" value="<?= $modx->manager->action ?>" /> |
@@ -576,54 +576,54 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | <h1> |
| 578 | 578 | <i class="fa fa-pencil-square-o"></i><?php if(isset($_REQUEST['id'])) { |
| 579 | - echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>'; |
|
| 580 | - } else { |
|
| 581 | - if ($modx->manager->action == '4') { |
|
| 579 | + echo iconv_substr($content['pagetitle'], 0, 50, $modx->config['modx_charset']) . (iconv_strlen($content['pagetitle'], $modx->config['modx_charset']) > 50 ? '...' : '') . '<small>(' . $_REQUEST['id'] . ')</small>'; |
|
| 580 | + } else { |
|
| 581 | + if ($modx->manager->action == '4') { |
|
| 582 | 582 | echo $_lang['add_resource']; |
| 583 | 583 | } else if ($modx->manager->action == '72') { |
| 584 | 584 | echo $_lang['add_weblink']; |
| 585 | 585 | } else { |
| 586 | 586 | echo $_lang['create_resource_title']; |
| 587 | 587 | } |
| 588 | - } ?> |
|
| 588 | + } ?> |
|
| 589 | 589 | </h1> |
| 590 | 590 | |
| 591 | 591 | <?= $_style['actionbuttons']['dynamic']['document'] ?> |
| 592 | 592 | |
| 593 | 593 | <?php |
| 594 | - // breadcrumbs |
|
| 595 | - if($modx->config['use_breadcrumbs']) { |
|
| 596 | - $temp = array(); |
|
| 597 | - $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
|
| 598 | - |
|
| 599 | - if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | - $bID = (int) $_REQUEST['id']; |
|
| 601 | - $temp = $modx->getParentIds($bID); |
|
| 602 | - } else if(isset($_REQUEST['pid'])) { |
|
| 603 | - $bID = (int) $_REQUEST['pid']; |
|
| 604 | - $temp = $modx->getParentIds($bID); |
|
| 605 | - array_unshift($temp, $bID); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - if($temp) { |
|
| 609 | - $parents = implode(',', $temp); |
|
| 610 | - |
|
| 611 | - if(!empty($parents)) { |
|
| 612 | - $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
|
| 613 | - $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
|
| 614 | - while($row = $modx->db->getRow($rs)) { |
|
| 615 | - $out .= '<li class="breadcrumbs__li"> |
|
| 594 | + // breadcrumbs |
|
| 595 | + if($modx->config['use_breadcrumbs']) { |
|
| 596 | + $temp = array(); |
|
| 597 | + $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
|
| 598 | + |
|
| 599 | + if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | + $bID = (int) $_REQUEST['id']; |
|
| 601 | + $temp = $modx->getParentIds($bID); |
|
| 602 | + } else if(isset($_REQUEST['pid'])) { |
|
| 603 | + $bID = (int) $_REQUEST['pid']; |
|
| 604 | + $temp = $modx->getParentIds($bID); |
|
| 605 | + array_unshift($temp, $bID); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + if($temp) { |
|
| 609 | + $parents = implode(',', $temp); |
|
| 610 | + |
|
| 611 | + if(!empty($parents)) { |
|
| 612 | + $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
|
| 613 | + $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
|
| 614 | + while($row = $modx->db->getRow($rs)) { |
|
| 615 | + $out .= '<li class="breadcrumbs__li"> |
|
| 616 | 616 | <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a> |
| 617 | 617 | <span class="breadcrumbs__sep">></span> |
| 618 | 618 | </li>'; |
| 619 | - } |
|
| 620 | - } |
|
| 621 | - } |
|
| 619 | + } |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | - $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | - echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 625 | - } |
|
| 626 | - ?> |
|
| 623 | + $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | + echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 625 | + } |
|
| 626 | + ?> |
|
| 627 | 627 | |
| 628 | 628 | <!-- start main wrapper --> |
| 629 | 629 | <div class="sectionBody"> |
@@ -635,13 +635,13 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | <!-- General --> |
| 637 | 637 | <?php |
| 638 | - $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
|
| 639 | - 'id' => $id |
|
| 640 | - )); |
|
| 641 | - if(is_array($evtOut)) { |
|
| 642 | - echo implode('', $evtOut); |
|
| 643 | - } else { |
|
| 644 | - ?> |
|
| 638 | + $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
|
| 639 | + 'id' => $id |
|
| 640 | + )); |
|
| 641 | + if(is_array($evtOut)) { |
|
| 642 | + echo implode('', $evtOut); |
|
| 643 | + } else { |
|
| 644 | + ?> |
|
| 645 | 645 | <div class="tab-page" id="tabGeneral"> |
| 646 | 646 | <h2 class="tab"><?= $_lang['settings_general'] ?></h2> |
| 647 | 647 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById("tabGeneral"));</script> |
@@ -726,36 +726,36 @@ discard block |
||
| 726 | 726 | <select id="template" name="template" class="inputBox" onchange="templateWarning();"> |
| 727 | 727 | <option value="0">(blank)</option> |
| 728 | 728 | <?php |
| 729 | - $field = "t.templatename, t.selectable, t.id, c.category"; |
|
| 730 | - $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
|
| 731 | - $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
|
| 732 | - $currentCategory = ''; |
|
| 733 | - while($row = $modx->db->getRow($rs)) { |
|
| 734 | - if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | - continue; |
|
| 736 | - }; |
|
| 737 | - // Skip if not selectable but show if selected! |
|
| 738 | - $thisCategory = $row['category']; |
|
| 739 | - if($thisCategory == null) { |
|
| 740 | - $thisCategory = $_lang["no_category"]; |
|
| 741 | - } |
|
| 742 | - if($thisCategory != $currentCategory) { |
|
| 743 | - if($closeOptGroup) { |
|
| 744 | - echo "\t\t\t\t\t</optgroup>\n"; |
|
| 745 | - } |
|
| 746 | - echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
|
| 747 | - $closeOptGroup = true; |
|
| 748 | - } |
|
| 729 | + $field = "t.templatename, t.selectable, t.id, c.category"; |
|
| 730 | + $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
|
| 731 | + $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
|
| 732 | + $currentCategory = ''; |
|
| 733 | + while($row = $modx->db->getRow($rs)) { |
|
| 734 | + if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | + continue; |
|
| 736 | + }; |
|
| 737 | + // Skip if not selectable but show if selected! |
|
| 738 | + $thisCategory = $row['category']; |
|
| 739 | + if($thisCategory == null) { |
|
| 740 | + $thisCategory = $_lang["no_category"]; |
|
| 741 | + } |
|
| 742 | + if($thisCategory != $currentCategory) { |
|
| 743 | + if($closeOptGroup) { |
|
| 744 | + echo "\t\t\t\t\t</optgroup>\n"; |
|
| 745 | + } |
|
| 746 | + echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
|
| 747 | + $closeOptGroup = true; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
|
| 750 | + $selectedtext = ($row['id'] == $content['template']) ? ' selected="selected"' : ''; |
|
| 751 | 751 | |
| 752 | - echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
|
| 753 | - $currentCategory = $thisCategory; |
|
| 754 | - } |
|
| 755 | - if($thisCategory != '') { |
|
| 756 | - echo "\t\t\t\t\t</optgroup>\n"; |
|
| 757 | - } |
|
| 758 | - ?> |
|
| 752 | + echo "\t\t\t\t\t" . '<option value="' . $row['id'] . '"' . $selectedtext . '>' . $row['templatename'] . "</option>\n"; |
|
| 753 | + $currentCategory = $thisCategory; |
|
| 754 | + } |
|
| 755 | + if($thisCategory != '') { |
|
| 756 | + echo "\t\t\t\t\t</optgroup>\n"; |
|
| 757 | + } |
|
| 758 | + ?> |
|
| 759 | 759 | </select> |
| 760 | 760 | </td> |
| 761 | 761 | </tr> |
@@ -795,37 +795,37 @@ discard block |
||
| 795 | 795 | </td> |
| 796 | 796 | <td valign="top"> |
| 797 | 797 | <?php |
| 798 | - $parentlookup = false; |
|
| 799 | - if(isset ($_REQUEST['id'])) { |
|
| 800 | - if($content['parent'] == 0) { |
|
| 801 | - $parentname = $site_name; |
|
| 802 | - } else { |
|
| 803 | - $parentlookup = $content['parent']; |
|
| 804 | - } |
|
| 805 | - } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | - if($_REQUEST['pid'] == 0) { |
|
| 807 | - $parentname = $site_name; |
|
| 808 | - } else { |
|
| 809 | - $parentlookup = $_REQUEST['pid']; |
|
| 810 | - } |
|
| 811 | - } elseif(isset($_POST['parent'])) { |
|
| 812 | - if($_POST['parent'] == 0) { |
|
| 813 | - $parentname = $site_name; |
|
| 814 | - } else { |
|
| 815 | - $parentlookup = $_POST['parent']; |
|
| 816 | - } |
|
| 817 | - } else { |
|
| 818 | - $parentname = $site_name; |
|
| 819 | - $content['parent'] = 0; |
|
| 820 | - } |
|
| 821 | - if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | - $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
|
| 823 | - $parentname = $modx->db->getValue($rs); |
|
| 824 | - if(!$parentname) { |
|
| 825 | - $modx->webAlertAndQuit($_lang["error_no_parent"]); |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - ?> |
|
| 798 | + $parentlookup = false; |
|
| 799 | + if(isset ($_REQUEST['id'])) { |
|
| 800 | + if($content['parent'] == 0) { |
|
| 801 | + $parentname = $site_name; |
|
| 802 | + } else { |
|
| 803 | + $parentlookup = $content['parent']; |
|
| 804 | + } |
|
| 805 | + } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | + if($_REQUEST['pid'] == 0) { |
|
| 807 | + $parentname = $site_name; |
|
| 808 | + } else { |
|
| 809 | + $parentlookup = $_REQUEST['pid']; |
|
| 810 | + } |
|
| 811 | + } elseif(isset($_POST['parent'])) { |
|
| 812 | + if($_POST['parent'] == 0) { |
|
| 813 | + $parentname = $site_name; |
|
| 814 | + } else { |
|
| 815 | + $parentlookup = $_POST['parent']; |
|
| 816 | + } |
|
| 817 | + } else { |
|
| 818 | + $parentname = $site_name; |
|
| 819 | + $content['parent'] = 0; |
|
| 820 | + } |
|
| 821 | + if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | + $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
|
| 823 | + $parentname = $modx->db->getValue($rs); |
|
| 824 | + if(!$parentname) { |
|
| 825 | + $modx->webAlertAndQuit($_lang["error_no_parent"]); |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | + ?> |
|
| 829 | 829 | <i id="plock" class="<?= $_style["actions_folder"] ?>" onclick="enableParentSelection(!allowParentSelection);"></i> |
| 830 | 830 | <b><span id="parentName"><?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?> (<?= $parentname ?>)</span></b> |
| 831 | 831 | <input type="hidden" name="parent" value="<?= (isset($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent']) ?>" onchange="documentDirty=true;" /> |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | </tr> |
| 834 | 834 | <tr></tr> |
| 835 | 835 | <?php |
| 836 | - /* |
|
| 836 | + /* |
|
| 837 | 837 | if($content['type'] == 'reference' || $modx->manager->action == '72') { |
| 838 | 838 | ?> |
| 839 | 839 | <tr> |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | </tr> |
| 862 | 862 | <?php |
| 863 | 863 | }*/ |
| 864 | - ?> |
|
| 864 | + ?> |
|
| 865 | 865 | |
| 866 | 866 | <?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
| 867 | 867 | <tr> |
@@ -874,36 +874,36 @@ discard block |
||
| 874 | 874 | <select id="which_editor" class="form-control form-control-sm" size="1" name="which_editor" onchange="changeRTE();"> |
| 875 | 875 | <option value="none"><?= $_lang['none'] ?></option> |
| 876 | 876 | <?php |
| 877 | - // invoke OnRichTextEditorRegister event |
|
| 878 | - $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
|
| 879 | - if(is_array($evtOut)) { |
|
| 880 | - for($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | - $editor = $evtOut[$i]; |
|
| 882 | - echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - ?> |
|
| 877 | + // invoke OnRichTextEditorRegister event |
|
| 878 | + $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
|
| 879 | + if(is_array($evtOut)) { |
|
| 880 | + for($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | + $editor = $evtOut[$i]; |
|
| 882 | + echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + ?> |
|
| 886 | 886 | </select> |
| 887 | 887 | </label> |
| 888 | 888 | </div> |
| 889 | 889 | <div id="content_body"> |
| 890 | 890 | <?php |
| 891 | - if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | - $htmlContent = $content['content']; |
|
| 893 | - ?> |
|
| 891 | + if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | + $htmlContent = $content['content']; |
|
| 893 | + ?> |
|
| 894 | 894 | <div class="section-editor clearfix"> |
| 895 | 895 | <textarea id="ta" name="ta" onchange="documentDirty=true;"><?= $modx->htmlspecialchars($htmlContent) ?></textarea> |
| 896 | 896 | </div> |
| 897 | 897 | <?php |
| 898 | - // Richtext-[*content*] |
|
| 899 | - $richtexteditorIds = array(); |
|
| 900 | - $richtexteditorOptions = array(); |
|
| 901 | - $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
|
| 902 | - $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
|
| 903 | - } else { |
|
| 904 | - echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
|
| 905 | - } |
|
| 906 | - ?> |
|
| 898 | + // Richtext-[*content*] |
|
| 899 | + $richtexteditorIds = array(); |
|
| 900 | + $richtexteditorOptions = array(); |
|
| 901 | + $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
|
| 902 | + $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
|
| 903 | + } else { |
|
| 904 | + echo "\t" . '<div><textarea class="phptextarea" id="ta" name="ta" rows="20" wrap="soft" onchange="documentDirty=true;">', $modx->htmlspecialchars($content['content']), '</textarea></div>' . "\n"; |
|
| 905 | + } |
|
| 906 | + ?> |
|
| 907 | 907 | </div> |
| 908 | 908 | </td> |
| 909 | 909 | </tr> |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | <?php |
| 1192 | 1192 | |
| 1193 | - if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1194 | - ?> |
|
| 1193 | + if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1194 | + ?> |
|
| 1195 | 1195 | <tr> |
| 1196 | 1196 | <td> |
| 1197 | 1197 | <span class="warning"><?= $_lang['resource_type'] ?></span> |
@@ -1213,15 +1213,15 @@ discard block |
||
| 1213 | 1213 | <td> |
| 1214 | 1214 | <select name="contentType" class="inputBox" onchange="documentDirty=true;"> |
| 1215 | 1215 | <?php |
| 1216 | - if(!$content['contentType']) { |
|
| 1217 | - $content['contentType'] = 'text/html'; |
|
| 1218 | - } |
|
| 1219 | - $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
|
| 1220 | - $ct = explode(",", $custom_contenttype); |
|
| 1221 | - for($i = 0; $i < count($ct); $i++) { |
|
| 1222 | - echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1223 | - } |
|
| 1224 | - ?> |
|
| 1216 | + if(!$content['contentType']) { |
|
| 1217 | + $content['contentType'] = 'text/html'; |
|
| 1218 | + } |
|
| 1219 | + $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
|
| 1220 | + $ct = explode(",", $custom_contenttype); |
|
| 1221 | + for($i = 0; $i < count($ct); $i++) { |
|
| 1222 | + echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1223 | + } |
|
| 1224 | + ?> |
|
| 1225 | 1225 | </select> |
| 1226 | 1226 | </td> |
| 1227 | 1227 | </tr> |
@@ -1244,23 +1244,23 @@ discard block |
||
| 1244 | 1244 | </td> |
| 1245 | 1245 | </tr> |
| 1246 | 1246 | <?php |
| 1247 | - } else { |
|
| 1248 | - if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1249 | - // non-admin managers creating or editing a document resource |
|
| 1250 | - ?> |
|
| 1247 | + } else { |
|
| 1248 | + if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1249 | + // non-admin managers creating or editing a document resource |
|
| 1250 | + ?> |
|
| 1251 | 1251 | <input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" /> |
| 1252 | 1252 | <input type="hidden" name="type" value="document" /> |
| 1253 | 1253 | <input type="hidden" name="content_dispo" value="<?= (isset($content['content_dispo']) ? $content['content_dispo'] : '0') ?>" /> |
| 1254 | 1254 | <?php |
| 1255 | - } else { |
|
| 1256 | - // non-admin managers creating or editing a reference (weblink) resource |
|
| 1257 | - ?> |
|
| 1255 | + } else { |
|
| 1256 | + // non-admin managers creating or editing a reference (weblink) resource |
|
| 1257 | + ?> |
|
| 1258 | 1258 | <input type="hidden" name="type" value="reference" /> |
| 1259 | 1259 | <input type="hidden" name="contentType" value="text/html" /> |
| 1260 | 1260 | <?php |
| 1261 | - } |
|
| 1262 | - }//if mgrRole |
|
| 1263 | - ?> |
|
| 1261 | + } |
|
| 1262 | + }//if mgrRole |
|
| 1263 | + ?> |
|
| 1264 | 1264 | |
| 1265 | 1265 | <tr> |
| 1266 | 1266 | <td> |
@@ -1343,112 +1343,112 @@ discard block |
||
| 1343 | 1343 | ?> |
| 1344 | 1344 | |
| 1345 | 1345 | <?php |
| 1346 | - /******************************* |
|
| 1346 | + /******************************* |
|
| 1347 | 1347 | * Document Access Permissions */ |
| 1348 | - if($use_udperms == 1) { |
|
| 1349 | - $groupsarray = array(); |
|
| 1350 | - $sql = ''; |
|
| 1351 | - |
|
| 1352 | - $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
|
| 1353 | - if($documentId > 0) { |
|
| 1354 | - // Load up, the permissions from the parent (if new document) or existing document |
|
| 1355 | - $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
|
| 1356 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1357 | - |
|
| 1358 | - // Load up the current permissions and names |
|
| 1359 | - $vs = array( |
|
| 1360 | - $tbl_document_group_names, |
|
| 1361 | - $tbl_document_groups, |
|
| 1362 | - $documentId |
|
| 1363 | - ); |
|
| 1364 | - $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs); |
|
| 1365 | - $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name'); |
|
| 1366 | - } else { |
|
| 1367 | - // Just load up the names, we're starting clean |
|
| 1368 | - $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name'); |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - // retain selected doc groups between post |
|
| 1372 | - if(isset($_POST['docgroups'])) { |
|
| 1373 | - $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
|
| 1374 | - } |
|
| 1348 | + if($use_udperms == 1) { |
|
| 1349 | + $groupsarray = array(); |
|
| 1350 | + $sql = ''; |
|
| 1351 | + |
|
| 1352 | + $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
|
| 1353 | + if($documentId > 0) { |
|
| 1354 | + // Load up, the permissions from the parent (if new document) or existing document |
|
| 1355 | + $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
|
| 1356 | + while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1357 | + |
|
| 1358 | + // Load up the current permissions and names |
|
| 1359 | + $vs = array( |
|
| 1360 | + $tbl_document_group_names, |
|
| 1361 | + $tbl_document_groups, |
|
| 1362 | + $documentId |
|
| 1363 | + ); |
|
| 1364 | + $from = vsprintf("%s AS dgn LEFT JOIN %s AS groups ON groups.document_group=dgn.id AND groups.document='%s'", $vs); |
|
| 1365 | + $rs = $modx->db->select('dgn.*, groups.id AS link_id', $from, '', 'name'); |
|
| 1366 | + } else { |
|
| 1367 | + // Just load up the names, we're starting clean |
|
| 1368 | + $rs = $modx->db->select('*, NULL AS link_id', $tbl_document_group_names, '', 'name'); |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + // retain selected doc groups between post |
|
| 1372 | + if(isset($_POST['docgroups'])) { |
|
| 1373 | + $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + $isManager = $modx->hasPermission('access_permissions'); |
|
| 1377 | + $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 1378 | + |
|
| 1379 | + // Setup Basic attributes for each Input box |
|
| 1380 | + $inputAttributes = array( |
|
| 1381 | + 'type' => 'checkbox', |
|
| 1382 | + 'class' => 'checkbox', |
|
| 1383 | + 'name' => 'docgroups[]', |
|
| 1384 | + 'onclick' => 'makePublic(false);', |
|
| 1385 | + ); |
|
| 1386 | + $permissions = array(); // New Permissions array list (this contains the HTML) |
|
| 1387 | + $permissions_yes = 0; // count permissions the current mgr user has |
|
| 1388 | + $permissions_no = 0; // count permissions the current mgr user doesn't have |
|
| 1389 | + |
|
| 1390 | + // Loop through the permissions list |
|
| 1391 | + while($row = $modx->db->getRow($rs)) { |
|
| 1392 | + |
|
| 1393 | + // Create an inputValue pair (group ID and group link (if it exists)) |
|
| 1394 | + $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | + $inputId = 'group-' . $row['id']; |
|
| 1396 | + |
|
| 1397 | + $checked = in_array($inputValue, $groupsarray); |
|
| 1398 | + if($checked) { |
|
| 1399 | + $notPublic = true; |
|
| 1400 | + } // Mark as private access (either web or manager) |
|
| 1401 | + |
|
| 1402 | + // Skip the access permission if the user doesn't have access... |
|
| 1403 | + if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1404 | + continue; |
|
| 1405 | + } |
|
| 1375 | 1406 | |
| 1376 | - $isManager = $modx->hasPermission('access_permissions'); |
|
| 1377 | - $isWeb = $modx->hasPermission('web_access_permissions'); |
|
| 1378 | - |
|
| 1379 | - // Setup Basic attributes for each Input box |
|
| 1380 | - $inputAttributes = array( |
|
| 1381 | - 'type' => 'checkbox', |
|
| 1382 | - 'class' => 'checkbox', |
|
| 1383 | - 'name' => 'docgroups[]', |
|
| 1384 | - 'onclick' => 'makePublic(false);', |
|
| 1385 | - ); |
|
| 1386 | - $permissions = array(); // New Permissions array list (this contains the HTML) |
|
| 1387 | - $permissions_yes = 0; // count permissions the current mgr user has |
|
| 1388 | - $permissions_no = 0; // count permissions the current mgr user doesn't have |
|
| 1389 | - |
|
| 1390 | - // Loop through the permissions list |
|
| 1391 | - while($row = $modx->db->getRow($rs)) { |
|
| 1392 | - |
|
| 1393 | - // Create an inputValue pair (group ID and group link (if it exists)) |
|
| 1394 | - $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1395 | - $inputId = 'group-' . $row['id']; |
|
| 1396 | - |
|
| 1397 | - $checked = in_array($inputValue, $groupsarray); |
|
| 1398 | - if($checked) { |
|
| 1399 | - $notPublic = true; |
|
| 1400 | - } // Mark as private access (either web or manager) |
|
| 1401 | - |
|
| 1402 | - // Skip the access permission if the user doesn't have access... |
|
| 1403 | - if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1404 | - continue; |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - // Setup attributes for this Input box |
|
| 1408 | - $inputAttributes['id'] = $inputId; |
|
| 1409 | - $inputAttributes['value'] = $inputValue; |
|
| 1410 | - if($checked) { |
|
| 1411 | - $inputAttributes['checked'] = 'checked'; |
|
| 1412 | - } else { |
|
| 1413 | - unset($inputAttributes['checked']); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - // Create attribute string list |
|
| 1417 | - $inputString = array(); |
|
| 1418 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1419 | - |
|
| 1420 | - // Make the <input> HTML |
|
| 1421 | - $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1422 | - |
|
| 1423 | - // does user have this permission? |
|
| 1424 | - $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
|
| 1425 | - $vs = array( |
|
| 1426 | - $row['id'], |
|
| 1427 | - $_SESSION['mgrInternalKey'] |
|
| 1428 | - ); |
|
| 1429 | - $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
|
| 1430 | - $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
|
| 1431 | - $count = $modx->db->getValue($rsp); |
|
| 1432 | - if($count > 0) { |
|
| 1433 | - ++$permissions_yes; |
|
| 1434 | - } else { |
|
| 1435 | - ++$permissions_no; |
|
| 1436 | - } |
|
| 1437 | - $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1438 | - } |
|
| 1439 | - // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
|
| 1440 | - if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1441 | - $permissions = array(); |
|
| 1442 | - } |
|
| 1407 | + // Setup attributes for this Input box |
|
| 1408 | + $inputAttributes['id'] = $inputId; |
|
| 1409 | + $inputAttributes['value'] = $inputValue; |
|
| 1410 | + if($checked) { |
|
| 1411 | + $inputAttributes['checked'] = 'checked'; |
|
| 1412 | + } else { |
|
| 1413 | + unset($inputAttributes['checked']); |
|
| 1414 | + } |
|
| 1443 | 1415 | |
| 1444 | - // See if the Access Permissions section is worth displaying... |
|
| 1445 | - if(!empty($permissions)) { |
|
| 1446 | - // Add the "All Document Groups" item if we have rights in both contexts |
|
| 1447 | - if($isManager && $isWeb) { |
|
| 1448 | - array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
|
| 1449 | - } |
|
| 1450 | - // Output the permissions list... |
|
| 1451 | - ?> |
|
| 1416 | + // Create attribute string list |
|
| 1417 | + $inputString = array(); |
|
| 1418 | + foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1419 | + |
|
| 1420 | + // Make the <input> HTML |
|
| 1421 | + $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1422 | + |
|
| 1423 | + // does user have this permission? |
|
| 1424 | + $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
|
| 1425 | + $vs = array( |
|
| 1426 | + $row['id'], |
|
| 1427 | + $_SESSION['mgrInternalKey'] |
|
| 1428 | + ); |
|
| 1429 | + $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
|
| 1430 | + $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
|
| 1431 | + $count = $modx->db->getValue($rsp); |
|
| 1432 | + if($count > 0) { |
|
| 1433 | + ++$permissions_yes; |
|
| 1434 | + } else { |
|
| 1435 | + ++$permissions_no; |
|
| 1436 | + } |
|
| 1437 | + $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1438 | + } |
|
| 1439 | + // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
|
| 1440 | + if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1441 | + $permissions = array(); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + // See if the Access Permissions section is worth displaying... |
|
| 1445 | + if(!empty($permissions)) { |
|
| 1446 | + // Add the "All Document Groups" item if we have rights in both contexts |
|
| 1447 | + if($isManager && $isWeb) { |
|
| 1448 | + array_unshift($permissions, "\t\t" . '<li><input type="checkbox" class="checkbox" name="chkalldocs" id="groupall"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true);" /><label for="groupall" class="warning">' . $_lang['all_doc_groups'] . '</label></li>'); |
|
| 1449 | + } |
|
| 1450 | + // Output the permissions list... |
|
| 1451 | + ?> |
|
| 1452 | 1452 | <!-- Access Permissions --> |
| 1453 | 1453 | <div class="tab-page" id="tabAccess"> |
| 1454 | 1454 | <h2 class="tab" id="tab_access_header"><?= $_lang['access_permissions'] ?></h2> |
@@ -1482,31 +1482,31 @@ discard block |
||
| 1482 | 1482 | </ul> |
| 1483 | 1483 | </div><!--div class="tab-page" id="tabAccess"--> |
| 1484 | 1484 | <?php |
| 1485 | - } // !empty($permissions) |
|
| 1486 | - elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1487 | - ?> |
|
| 1485 | + } // !empty($permissions) |
|
| 1486 | + elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1487 | + ?> |
|
| 1488 | 1488 | <p><?= $_lang["access_permissions_docs_collision"] ?></p> |
| 1489 | 1489 | <?php |
| 1490 | 1490 | |
| 1491 | - } |
|
| 1492 | - } |
|
| 1493 | - /* End Document Access Permissions * |
|
| 1491 | + } |
|
| 1492 | + } |
|
| 1493 | + /* End Document Access Permissions * |
|
| 1494 | 1494 | ***********************************/ |
| 1495 | - ?> |
|
| 1495 | + ?> |
|
| 1496 | 1496 | |
| 1497 | 1497 | <input type="submit" name="save" style="display:none" /> |
| 1498 | 1498 | <?php |
| 1499 | 1499 | |
| 1500 | - // invoke OnDocFormRender event |
|
| 1501 | - $evtOut = $modx->invokeEvent('OnDocFormRender', array( |
|
| 1502 | - 'id' => $id, |
|
| 1503 | - 'template' => $content['template'] |
|
| 1504 | - )); |
|
| 1500 | + // invoke OnDocFormRender event |
|
| 1501 | + $evtOut = $modx->invokeEvent('OnDocFormRender', array( |
|
| 1502 | + 'id' => $id, |
|
| 1503 | + 'template' => $content['template'] |
|
| 1504 | + )); |
|
| 1505 | 1505 | |
| 1506 | - if(is_array($evtOut)) { |
|
| 1507 | - echo implode('', $evtOut); |
|
| 1508 | - } |
|
| 1509 | - ?> |
|
| 1506 | + if(is_array($evtOut)) { |
|
| 1507 | + echo implode('', $evtOut); |
|
| 1508 | + } |
|
| 1509 | + ?> |
|
| 1510 | 1510 | </div><!--div class="tab-pane" id="documentPane"--> |
| 1511 | 1511 | </div><!--div class="sectionBody"--> |
| 1512 | 1512 | </fieldset> |
@@ -1517,62 +1517,62 @@ discard block |
||
| 1517 | 1517 | </script> |
| 1518 | 1518 | <?php |
| 1519 | 1519 | if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
| 1520 | - if(is_array($richtexteditorIds)) { |
|
| 1521 | - foreach($richtexteditorIds as $editor => $elements) { |
|
| 1522 | - // invoke OnRichTextEditorInit event |
|
| 1523 | - $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
|
| 1524 | - 'editor' => $editor, |
|
| 1525 | - 'elements' => $elements, |
|
| 1526 | - 'options' => $richtexteditorOptions[$editor] |
|
| 1527 | - )); |
|
| 1528 | - if(is_array($evtOut)) { |
|
| 1529 | - echo implode('', $evtOut); |
|
| 1530 | - } |
|
| 1531 | - } |
|
| 1532 | - } |
|
| 1520 | + if(is_array($richtexteditorIds)) { |
|
| 1521 | + foreach($richtexteditorIds as $editor => $elements) { |
|
| 1522 | + // invoke OnRichTextEditorInit event |
|
| 1523 | + $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
|
| 1524 | + 'editor' => $editor, |
|
| 1525 | + 'elements' => $elements, |
|
| 1526 | + 'options' => $richtexteditorOptions[$editor] |
|
| 1527 | + )); |
|
| 1528 | + if(is_array($evtOut)) { |
|
| 1529 | + echo implode('', $evtOut); |
|
| 1530 | + } |
|
| 1531 | + } |
|
| 1532 | + } |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | function getDefaultTemplate() { |
| 1536 | - global $modx; |
|
| 1537 | - |
|
| 1538 | - switch($modx->config['auto_template_logic']) { |
|
| 1539 | - case 'sibling': |
|
| 1540 | - if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1541 | - $site_start = $modx->config['site_start']; |
|
| 1542 | - $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1543 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1544 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1545 | - $default_template = $sibl[0]['template']; |
|
| 1546 | - } |
|
| 1547 | - } else { |
|
| 1548 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1549 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1550 | - $default_template = $sibl[0]['template']; |
|
| 1551 | - } else { |
|
| 1552 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | - $default_template = $sibl[0]['template']; |
|
| 1555 | - } |
|
| 1556 | - } |
|
| 1557 | - } |
|
| 1558 | - if(isset($default_template)) { |
|
| 1559 | - break; |
|
| 1560 | - } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1561 | - case 'parent': |
|
| 1562 | - if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1563 | - $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1564 | - if(isset($parent['template'])) { |
|
| 1565 | - $default_template = $parent['template']; |
|
| 1566 | - } |
|
| 1567 | - } |
|
| 1568 | - break; |
|
| 1569 | - case 'system': |
|
| 1570 | - default: // default_template is already set |
|
| 1571 | - $default_template = $modx->config['default_template']; |
|
| 1572 | - } |
|
| 1573 | - if(!isset($default_template)) { |
|
| 1574 | - $default_template = $modx->config['default_template']; |
|
| 1575 | - } // default_template is already set |
|
| 1576 | - |
|
| 1577 | - return $default_template; |
|
| 1536 | + global $modx; |
|
| 1537 | + |
|
| 1538 | + switch($modx->config['auto_template_logic']) { |
|
| 1539 | + case 'sibling': |
|
| 1540 | + if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1541 | + $site_start = $modx->config['site_start']; |
|
| 1542 | + $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1543 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1544 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1545 | + $default_template = $sibl[0]['template']; |
|
| 1546 | + } |
|
| 1547 | + } else { |
|
| 1548 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1549 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1550 | + $default_template = $sibl[0]['template']; |
|
| 1551 | + } else { |
|
| 1552 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | + $default_template = $sibl[0]['template']; |
|
| 1555 | + } |
|
| 1556 | + } |
|
| 1557 | + } |
|
| 1558 | + if(isset($default_template)) { |
|
| 1559 | + break; |
|
| 1560 | + } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1561 | + case 'parent': |
|
| 1562 | + if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1563 | + $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1564 | + if(isset($parent['template'])) { |
|
| 1565 | + $default_template = $parent['template']; |
|
| 1566 | + } |
|
| 1567 | + } |
|
| 1568 | + break; |
|
| 1569 | + case 'system': |
|
| 1570 | + default: // default_template is already set |
|
| 1571 | + $default_template = $modx->config['default_template']; |
|
| 1572 | + } |
|
| 1573 | + if(!isset($default_template)) { |
|
| 1574 | + $default_template = $modx->config['default_template']; |
|
| 1575 | + } // default_template is already set |
|
| 1576 | + |
|
| 1577 | + return $default_template; |
|
| 1578 | 1578 | } |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | 'type7' => $_lang["lock_element_type_7"], |
| 29 | 29 | 'type8' => $_lang["lock_element_type_8"] |
| 30 | 30 | ); |
| 31 | -foreach($unlockTranslations as $key => $value) $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
|
| 31 | +foreach($unlockTranslations as $key => $value) { |
|
| 32 | + $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
|
| 33 | +} |
|
| 32 | 34 | |
| 33 | 35 | // Prepare lang-strings for mgrResAction() |
| 34 | 36 | $mraTranslations = array( |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | 'confirm_delete_plugin' => $_lang["confirm_delete_plugin"], |
| 45 | 47 | 'confirm_delete_module' => $_lang["confirm_delete_module"], |
| 46 | 48 | ); |
| 47 | -foreach($mraTranslations as $key => $value) $mraTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
|
| 49 | +foreach($mraTranslations as $key => $value) { |
|
| 50 | + $mraTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
|
| 51 | +} |
|
| 48 | 52 | ?> |
| 49 | 53 | <script>var trans = <?php echo json_encode($unlockTranslations); ?>;</script> |
| 50 | 54 | <script>var mraTrans = <?php echo json_encode($mraTranslations); ?>;</script> |
@@ -1,48 +1,48 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/functions.inc.php')) { |
| 7 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/functions.inc.php'); |
|
| 7 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/functions.inc.php'); |
|
| 8 | 8 | } else { |
| 9 | - include_once(MODX_MANAGER_PATH . 'actions/resources/functions.inc.php'); |
|
| 9 | + include_once(MODX_MANAGER_PATH . 'actions/resources/functions.inc.php'); |
|
| 10 | 10 | } |
| 11 | 11 | if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/mgrResources.class.php')) { |
| 12 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/mgrResources.class.php'); |
|
| 12 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/mgrResources.class.php'); |
|
| 13 | 13 | } else { |
| 14 | - include_once(MODX_MANAGER_PATH . 'actions/resources/mgrResources.class.php'); |
|
| 14 | + include_once(MODX_MANAGER_PATH . 'actions/resources/mgrResources.class.php'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $resources = new mgrResources(); |
| 18 | 18 | |
| 19 | 19 | // Prepare lang-strings for "Lock Elements" |
| 20 | 20 | $unlockTranslations = array( |
| 21 | - 'msg' => $_lang["unlock_element_id_warning"], |
|
| 22 | - 'type1' => $_lang["lock_element_type_1"], |
|
| 23 | - 'type2' => $_lang["lock_element_type_2"], |
|
| 24 | - 'type3' => $_lang["lock_element_type_3"], |
|
| 25 | - 'type4' => $_lang["lock_element_type_4"], |
|
| 26 | - 'type5' => $_lang["lock_element_type_5"], |
|
| 27 | - 'type6' => $_lang["lock_element_type_6"], |
|
| 28 | - 'type7' => $_lang["lock_element_type_7"], |
|
| 29 | - 'type8' => $_lang["lock_element_type_8"] |
|
| 21 | + 'msg' => $_lang["unlock_element_id_warning"], |
|
| 22 | + 'type1' => $_lang["lock_element_type_1"], |
|
| 23 | + 'type2' => $_lang["lock_element_type_2"], |
|
| 24 | + 'type3' => $_lang["lock_element_type_3"], |
|
| 25 | + 'type4' => $_lang["lock_element_type_4"], |
|
| 26 | + 'type5' => $_lang["lock_element_type_5"], |
|
| 27 | + 'type6' => $_lang["lock_element_type_6"], |
|
| 28 | + 'type7' => $_lang["lock_element_type_7"], |
|
| 29 | + 'type8' => $_lang["lock_element_type_8"] |
|
| 30 | 30 | ); |
| 31 | 31 | foreach($unlockTranslations as $key => $value) $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
| 32 | 32 | |
| 33 | 33 | // Prepare lang-strings for mgrResAction() |
| 34 | 34 | $mraTranslations = array( |
| 35 | - 'create_new' => $_lang["create_new"], |
|
| 36 | - 'edit' => $_lang["edit"], |
|
| 37 | - 'duplicate' => $_lang["duplicate"], |
|
| 38 | - 'remove' => $_lang["remove"], |
|
| 39 | - 'confirm_duplicate_record' => $_lang["confirm_duplicate_record"], |
|
| 40 | - 'confirm_delete_template' => $_lang["confirm_delete_template"], |
|
| 41 | - 'confirm_delete_tmplvars' => $_lang["confirm_delete_tmplvars"], |
|
| 42 | - 'confirm_delete_htmlsnippet' => $_lang["confirm_delete_htmlsnippet"], |
|
| 43 | - 'confirm_delete_snippet' => $_lang["confirm_delete_htmlsnippet"], |
|
| 44 | - 'confirm_delete_plugin' => $_lang["confirm_delete_plugin"], |
|
| 45 | - 'confirm_delete_module' => $_lang["confirm_delete_module"], |
|
| 35 | + 'create_new' => $_lang["create_new"], |
|
| 36 | + 'edit' => $_lang["edit"], |
|
| 37 | + 'duplicate' => $_lang["duplicate"], |
|
| 38 | + 'remove' => $_lang["remove"], |
|
| 39 | + 'confirm_duplicate_record' => $_lang["confirm_duplicate_record"], |
|
| 40 | + 'confirm_delete_template' => $_lang["confirm_delete_template"], |
|
| 41 | + 'confirm_delete_tmplvars' => $_lang["confirm_delete_tmplvars"], |
|
| 42 | + 'confirm_delete_htmlsnippet' => $_lang["confirm_delete_htmlsnippet"], |
|
| 43 | + 'confirm_delete_snippet' => $_lang["confirm_delete_htmlsnippet"], |
|
| 44 | + 'confirm_delete_plugin' => $_lang["confirm_delete_plugin"], |
|
| 45 | + 'confirm_delete_module' => $_lang["confirm_delete_module"], |
|
| 46 | 46 | ); |
| 47 | 47 | foreach($mraTranslations as $key => $value) $mraTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
| 48 | 48 | ?> |
@@ -65,46 +65,46 @@ discard block |
||
| 65 | 65 | </script> |
| 66 | 66 | |
| 67 | 67 | <?php |
| 68 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab1_templates.inc.php')) { |
|
| 69 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab1_templates.inc.php'); |
|
| 70 | - } else { |
|
| 71 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab1_templates.inc.php'); |
|
| 72 | - } |
|
| 68 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab1_templates.inc.php')) { |
|
| 69 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab1_templates.inc.php'); |
|
| 70 | + } else { |
|
| 71 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab1_templates.inc.php'); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab2_templatevars.inc.php')) { |
|
| 75 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab2_templatevars.inc.php'); |
|
| 76 | - } else { |
|
| 77 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab2_templatevars.inc.php'); |
|
| 78 | - } |
|
| 74 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab2_templatevars.inc.php')) { |
|
| 75 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab2_templatevars.inc.php'); |
|
| 76 | + } else { |
|
| 77 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab2_templatevars.inc.php'); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab3_chunks.inc.php')) { |
|
| 81 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab3_chunks.inc.php'); |
|
| 82 | - } else { |
|
| 83 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab3_chunks.inc.php'); |
|
| 84 | - } |
|
| 80 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab3_chunks.inc.php')) { |
|
| 81 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab3_chunks.inc.php'); |
|
| 82 | + } else { |
|
| 83 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab3_chunks.inc.php'); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab4_snippets.inc.php')) { |
|
| 87 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab4_snippets.inc.php'); |
|
| 88 | - } else { |
|
| 89 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab4_snippets.inc.php'); |
|
| 90 | - } |
|
| 86 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab4_snippets.inc.php')) { |
|
| 87 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab4_snippets.inc.php'); |
|
| 88 | + } else { |
|
| 89 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab4_snippets.inc.php'); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab5_plugins.inc.php')) { |
|
| 93 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab5_plugins.inc.php'); |
|
| 94 | - } else { |
|
| 95 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab5_plugins.inc.php'); |
|
| 96 | - } |
|
| 92 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab5_plugins.inc.php')) { |
|
| 93 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab5_plugins.inc.php'); |
|
| 94 | + } else { |
|
| 95 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab5_plugins.inc.php'); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab6_categoryview.inc.php')) { |
|
| 99 | - include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab6_categoryview.inc.php'); |
|
| 100 | - } else { |
|
| 101 | - include_once(MODX_MANAGER_PATH . '/actions/resources/tab6_categoryview.inc.php'); |
|
| 102 | - } |
|
| 98 | + if(file_exists(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab6_categoryview.inc.php')) { |
|
| 99 | + include_once(MODX_MANAGER_PATH . '/media/style/' . $modx->config['manager_theme'] . '/actions/resources/tab6_categoryview.inc.php'); |
|
| 100 | + } else { |
|
| 101 | + include_once(MODX_MANAGER_PATH . '/actions/resources/tab6_categoryview.inc.php'); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - if(is_numeric($_GET['tab'])) { |
|
| 106 | - echo '<script type="text/javascript"> tpResources.setSelectedIndex( ' . $_GET['tab'] . ' );</script>'; |
|
| 107 | - } |
|
| 108 | - ?> |
|
| 105 | + if(is_numeric($_GET['tab'])) { |
|
| 106 | + echo '<script type="text/javascript"> tpResources.setSelectedIndex( ' . $_GET['tab'] . ' );</script>'; |
|
| 107 | + } |
|
| 108 | + ?> |
|
| 109 | 109 | </div> |
| 110 | 110 | </div> |
@@ -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 | |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
| 3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('import_static')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Files to upload |
| 10 | 10 | $allowedfiles = array( |
| 11 | - 'html', |
|
| 12 | - 'htm', |
|
| 13 | - 'shtml', |
|
| 14 | - 'xml' |
|
| 11 | + 'html', |
|
| 12 | + 'htm', |
|
| 13 | + 'shtml', |
|
| 14 | + 'xml' |
|
| 15 | 15 | ); |
| 16 | 16 | ?> |
| 17 | 17 | <script language="javascript"> |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | - ?> |
|
| 46 | + if(!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | + ?> |
|
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
| 51 | 51 | <input type="hidden" name="a" value="95" /> |
@@ -85,370 +85,370 @@ 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 | - $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 | + $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 | - $createdby = $modx->getLoginUserID(); |
|
| 172 | - if(!is_array($files)) { |
|
| 173 | - return; |
|
| 174 | - } |
|
| 175 | - if($_POST['object'] == 'all') { |
|
| 176 | - $modx->config['default_template'] = '0'; |
|
| 177 | - $richtext = '0'; |
|
| 178 | - } else { |
|
| 179 | - $richtext = '1'; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - foreach($files as $id => $value) { |
|
| 183 | - if(is_array($value)) { |
|
| 184 | - // create folder |
|
| 185 | - $alias = $id; |
|
| 186 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 187 | - $field = array(); |
|
| 188 | - $field['type'] = 'document'; |
|
| 189 | - $field['contentType'] = 'text/html'; |
|
| 190 | - $field['published'] = $publish_default; |
|
| 191 | - $field['parent'] = $parent; |
|
| 192 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 193 | - $field['richtext'] = $richtext; |
|
| 194 | - $field['template'] = $modx->config['default_template']; |
|
| 195 | - $field['searchable'] = $search_default; |
|
| 196 | - $field['cacheable'] = $cache_default; |
|
| 197 | - $field['createdby'] = $createdby; |
|
| 198 | - $field['isfolder'] = 1; |
|
| 199 | - $field['menuindex'] = 1; |
|
| 200 | - $find = false; |
|
| 201 | - foreach(array( |
|
| 202 | - 'index.html', |
|
| 203 | - 'index.htm' |
|
| 204 | - ) as $filename) { |
|
| 205 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 206 | - if($find === false && file_exists($filepath)) { |
|
| 207 | - $file = getFileContent($filepath); |
|
| 208 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 209 | - |
|
| 210 | - $date = filemtime($filepath); |
|
| 211 | - $field['pagetitle'] = $pagetitle; |
|
| 212 | - $field['longtitle'] = $pagetitle; |
|
| 213 | - $field['description'] = $description; |
|
| 214 | - $field['content'] = $modx->db->escape($content); |
|
| 215 | - $field['createdon'] = $date; |
|
| 216 | - $field['editedon'] = $date; |
|
| 217 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 218 | - if($newid) { |
|
| 219 | - $find = true; |
|
| 220 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 221 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 222 | - } else { |
|
| 223 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 224 | - exit; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - if($find === false) { |
|
| 229 | - $date = time(); |
|
| 230 | - $field['pagetitle'] = '---'; |
|
| 231 | - $field['content'] = ''; |
|
| 232 | - $field['createdon'] = $date; |
|
| 233 | - $field['editedon'] = $date; |
|
| 234 | - $field['hidemenu'] = '1'; |
|
| 235 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 236 | - if($newid) { |
|
| 237 | - $find = true; |
|
| 238 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 239 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 240 | - } else { |
|
| 241 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 242 | - exit; |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } else { |
|
| 246 | - // create document |
|
| 247 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 248 | - continue; |
|
| 249 | - } |
|
| 250 | - $filename = $value; |
|
| 251 | - $fparts = explode('.', $value); |
|
| 252 | - $alias = $fparts[0]; |
|
| 253 | - $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 254 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 255 | - |
|
| 256 | - if(!in_array($ext, $allowedfiles)) { |
|
| 257 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 258 | - } else { |
|
| 259 | - $filepath = $filedir . $filename; |
|
| 260 | - $file = getFileContent($filepath); |
|
| 261 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 262 | - |
|
| 263 | - $date = filemtime($filepath); |
|
| 264 | - $field = array(); |
|
| 265 | - $field['type'] = 'document'; |
|
| 266 | - $field['contentType'] = 'text/html'; |
|
| 267 | - $field['pagetitle'] = $pagetitle; |
|
| 268 | - $field['longtitle'] = $pagetitle; |
|
| 269 | - $field['description'] = $description; |
|
| 270 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 271 | - $field['published'] = $publish_default; |
|
| 272 | - $field['parent'] = $parent; |
|
| 273 | - $field['content'] = $modx->db->escape($content); |
|
| 274 | - $field['richtext'] = $richtext; |
|
| 275 | - $field['template'] = $modx->config['default_template']; |
|
| 276 | - $field['searchable'] = $search_default; |
|
| 277 | - $field['cacheable'] = $cache_default; |
|
| 278 | - $field['createdby'] = $createdby; |
|
| 279 | - $field['createdon'] = $date; |
|
| 280 | - $field['editedon'] = $date; |
|
| 281 | - $field['isfolder'] = 0; |
|
| 282 | - $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 283 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 284 | - if($newid) { |
|
| 285 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 286 | - } else { |
|
| 287 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 288 | - exit; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - $is_site_start = false; |
|
| 292 | - if($filename == 'index.html') { |
|
| 293 | - $is_site_start = true; |
|
| 294 | - } |
|
| 295 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 296 | - $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 297 | - $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 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 | + $createdby = $modx->getLoginUserID(); |
|
| 172 | + if(!is_array($files)) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 175 | + if($_POST['object'] == 'all') { |
|
| 176 | + $modx->config['default_template'] = '0'; |
|
| 177 | + $richtext = '0'; |
|
| 178 | + } else { |
|
| 179 | + $richtext = '1'; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + foreach($files as $id => $value) { |
|
| 183 | + if(is_array($value)) { |
|
| 184 | + // create folder |
|
| 185 | + $alias = $id; |
|
| 186 | + printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 187 | + $field = array(); |
|
| 188 | + $field['type'] = 'document'; |
|
| 189 | + $field['contentType'] = 'text/html'; |
|
| 190 | + $field['published'] = $publish_default; |
|
| 191 | + $field['parent'] = $parent; |
|
| 192 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 193 | + $field['richtext'] = $richtext; |
|
| 194 | + $field['template'] = $modx->config['default_template']; |
|
| 195 | + $field['searchable'] = $search_default; |
|
| 196 | + $field['cacheable'] = $cache_default; |
|
| 197 | + $field['createdby'] = $createdby; |
|
| 198 | + $field['isfolder'] = 1; |
|
| 199 | + $field['menuindex'] = 1; |
|
| 200 | + $find = false; |
|
| 201 | + foreach(array( |
|
| 202 | + 'index.html', |
|
| 203 | + 'index.htm' |
|
| 204 | + ) as $filename) { |
|
| 205 | + $filepath = $filedir . $alias . '/' . $filename; |
|
| 206 | + if($find === false && file_exists($filepath)) { |
|
| 207 | + $file = getFileContent($filepath); |
|
| 208 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 209 | + |
|
| 210 | + $date = filemtime($filepath); |
|
| 211 | + $field['pagetitle'] = $pagetitle; |
|
| 212 | + $field['longtitle'] = $pagetitle; |
|
| 213 | + $field['description'] = $description; |
|
| 214 | + $field['content'] = $modx->db->escape($content); |
|
| 215 | + $field['createdon'] = $date; |
|
| 216 | + $field['editedon'] = $date; |
|
| 217 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 218 | + if($newid) { |
|
| 219 | + $find = true; |
|
| 220 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 221 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 222 | + } else { |
|
| 223 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 224 | + exit; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + if($find === false) { |
|
| 229 | + $date = time(); |
|
| 230 | + $field['pagetitle'] = '---'; |
|
| 231 | + $field['content'] = ''; |
|
| 232 | + $field['createdon'] = $date; |
|
| 233 | + $field['editedon'] = $date; |
|
| 234 | + $field['hidemenu'] = '1'; |
|
| 235 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 236 | + if($newid) { |
|
| 237 | + $find = true; |
|
| 238 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 239 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 240 | + } else { |
|
| 241 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 242 | + exit; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } else { |
|
| 246 | + // create document |
|
| 247 | + if($mode == 'sub' && $value == 'index.html') { |
|
| 248 | + continue; |
|
| 249 | + } |
|
| 250 | + $filename = $value; |
|
| 251 | + $fparts = explode('.', $value); |
|
| 252 | + $alias = $fparts[0]; |
|
| 253 | + $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 254 | + printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 255 | + |
|
| 256 | + if(!in_array($ext, $allowedfiles)) { |
|
| 257 | + echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 258 | + } else { |
|
| 259 | + $filepath = $filedir . $filename; |
|
| 260 | + $file = getFileContent($filepath); |
|
| 261 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 262 | + |
|
| 263 | + $date = filemtime($filepath); |
|
| 264 | + $field = array(); |
|
| 265 | + $field['type'] = 'document'; |
|
| 266 | + $field['contentType'] = 'text/html'; |
|
| 267 | + $field['pagetitle'] = $pagetitle; |
|
| 268 | + $field['longtitle'] = $pagetitle; |
|
| 269 | + $field['description'] = $description; |
|
| 270 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 271 | + $field['published'] = $publish_default; |
|
| 272 | + $field['parent'] = $parent; |
|
| 273 | + $field['content'] = $modx->db->escape($content); |
|
| 274 | + $field['richtext'] = $richtext; |
|
| 275 | + $field['template'] = $modx->config['default_template']; |
|
| 276 | + $field['searchable'] = $search_default; |
|
| 277 | + $field['cacheable'] = $cache_default; |
|
| 278 | + $field['createdby'] = $createdby; |
|
| 279 | + $field['createdon'] = $date; |
|
| 280 | + $field['editedon'] = $date; |
|
| 281 | + $field['isfolder'] = 0; |
|
| 282 | + $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 283 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 284 | + if($newid) { |
|
| 285 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 286 | + } else { |
|
| 287 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 288 | + exit; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + $is_site_start = false; |
|
| 292 | + if($filename == 'index.html') { |
|
| 293 | + $is_site_start = true; |
|
| 294 | + } |
|
| 295 | + if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 296 | + $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 297 | + $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | function getFiles($directory, $listing = array(), $count = 0) { |
| 305 | - global $_lang; |
|
| 306 | - global $filesfound; |
|
| 307 | - $dummy = $count; |
|
| 308 | - if($files = scandir($directory)) { |
|
| 309 | - foreach($files as $file) { |
|
| 310 | - if($file == '.' || $file == '..') { |
|
| 311 | - continue; |
|
| 312 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 313 | - closedir($h); |
|
| 314 | - $count = -1; |
|
| 315 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 316 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 317 | - $listing[$dummy] = $file; |
|
| 318 | - $dummy = $dummy + 1; |
|
| 319 | - $filesfound++; |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } else { |
|
| 323 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 324 | - } |
|
| 325 | - return ($listing); |
|
| 305 | + global $_lang; |
|
| 306 | + global $filesfound; |
|
| 307 | + $dummy = $count; |
|
| 308 | + if($files = scandir($directory)) { |
|
| 309 | + foreach($files as $file) { |
|
| 310 | + if($file == '.' || $file == '..') { |
|
| 311 | + continue; |
|
| 312 | + } elseif($h = @opendir($directory . $file . "/")) { |
|
| 313 | + closedir($h); |
|
| 314 | + $count = -1; |
|
| 315 | + $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 316 | + } elseif(strpos($file, '.htm') !== false) { |
|
| 317 | + $listing[$dummy] = $file; |
|
| 318 | + $dummy = $dummy + 1; |
|
| 319 | + $filesfound++; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } else { |
|
| 323 | + echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 324 | + } |
|
| 325 | + return ($listing); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | function getFileContent($filepath) { |
| 329 | - global $_lang; |
|
| 330 | - // get the file |
|
| 331 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 332 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 333 | - } else { |
|
| 334 | - return $buffer; |
|
| 335 | - } |
|
| 329 | + global $_lang; |
|
| 330 | + // get the file |
|
| 331 | + if(!$buffer = file_get_contents($filepath)) { |
|
| 332 | + echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 333 | + } else { |
|
| 334 | + return $buffer; |
|
| 335 | + } |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | function pop_index($array) { |
| 339 | - $new_array = array(); |
|
| 340 | - foreach($array as $k => $v) { |
|
| 341 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 342 | - $new_array[$k] = $v; |
|
| 343 | - } else { |
|
| 344 | - array_unshift($new_array, $v); |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - foreach($array as $k => $v) { |
|
| 348 | - if(is_array($v)) { |
|
| 349 | - $new_array[$k] = $v; |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - return $new_array; |
|
| 339 | + $new_array = array(); |
|
| 340 | + foreach($array as $k => $v) { |
|
| 341 | + if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 342 | + $new_array[$k] = $v; |
|
| 343 | + } else { |
|
| 344 | + array_unshift($new_array, $v); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + foreach($array as $k => $v) { |
|
| 348 | + if(is_array($v)) { |
|
| 349 | + $new_array[$k] = $v; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + return $new_array; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function treatContent($src, $filename, $alias) { |
| 356 | - global $modx; |
|
| 357 | - |
|
| 358 | - $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 359 | - |
|
| 360 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 361 | - $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 362 | - $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 363 | - } else { |
|
| 364 | - $pagetitle = $alias; |
|
| 365 | - } |
|
| 366 | - if(!$pagetitle) { |
|
| 367 | - $pagetitle = $alias; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 371 | - $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 372 | - $description = str_replace('[*description*]', '', $description); |
|
| 373 | - } else { |
|
| 374 | - $description = ''; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 378 | - $content = $matches[1]; |
|
| 379 | - } else { |
|
| 380 | - $content = $src; |
|
| 381 | - $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 382 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 383 | - $content = preg_replace($s, $r, $content); |
|
| 384 | - $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 385 | - } |
|
| 386 | - $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 387 | - $content = trim($content); |
|
| 388 | - $pagetitle = $modx->db->escape($pagetitle); |
|
| 389 | - return array( |
|
| 390 | - $pagetitle, |
|
| 391 | - $content, |
|
| 392 | - $description |
|
| 393 | - ); |
|
| 356 | + global $modx; |
|
| 357 | + |
|
| 358 | + $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 359 | + |
|
| 360 | + if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 361 | + $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 362 | + $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 363 | + } else { |
|
| 364 | + $pagetitle = $alias; |
|
| 365 | + } |
|
| 366 | + if(!$pagetitle) { |
|
| 367 | + $pagetitle = $alias; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 371 | + $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 372 | + $description = str_replace('[*description*]', '', $description); |
|
| 373 | + } else { |
|
| 374 | + $description = ''; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 378 | + $content = $matches[1]; |
|
| 379 | + } else { |
|
| 380 | + $content = $src; |
|
| 381 | + $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 382 | + $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 383 | + $content = preg_replace($s, $r, $content); |
|
| 384 | + $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 385 | + } |
|
| 386 | + $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 387 | + $content = trim($content); |
|
| 388 | + $pagetitle = $modx->db->escape($pagetitle); |
|
| 389 | + return array( |
|
| 390 | + $pagetitle, |
|
| 391 | + $content, |
|
| 392 | + $description |
|
| 393 | + ); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | function convertLink() { |
| 397 | - global $modx; |
|
| 398 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 399 | - |
|
| 400 | - $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 401 | - while($row = $modx->db->getRow($rs)) { |
|
| 402 | - $id = $row['id']; |
|
| 403 | - $array = explode('<a href=', $row['content']); |
|
| 404 | - $c = 0; |
|
| 405 | - foreach($array as $v) { |
|
| 406 | - if($v[0] === '"') { |
|
| 407 | - $v = substr($v, 1); |
|
| 408 | - list($href, $v) = explode('"', $v, 2); |
|
| 409 | - $_ = $href; |
|
| 410 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 411 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 412 | - } |
|
| 413 | - if($_[0] === '/') { |
|
| 414 | - $_ = substr($_, 1); |
|
| 415 | - } |
|
| 416 | - $_ = str_replace('/index.html', '.html', $_); |
|
| 417 | - $level = substr_count($_, '../'); |
|
| 418 | - if(1 < $level) { |
|
| 419 | - if(!isset($p[$id])) { |
|
| 420 | - $p[$id] = $modx->getParentIds($id); |
|
| 421 | - } |
|
| 422 | - $k = array_keys($p[$id]); |
|
| 423 | - while(0 < $level) { |
|
| 424 | - $dir = array_shift($k); |
|
| 425 | - $level--; |
|
| 426 | - } |
|
| 427 | - if($dir != '') { |
|
| 428 | - $dir .= '/'; |
|
| 429 | - } |
|
| 430 | - } else { |
|
| 431 | - $dir = ''; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - $_ = trim($_, './'); |
|
| 435 | - if(strpos($_, '/') !== false) { |
|
| 436 | - $_ = substr($_, strrpos($_, '/')); |
|
| 437 | - } |
|
| 438 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 439 | - if(!isset($target[$_])) { |
|
| 440 | - $target[$_] = $modx->getIdFromAlias($_); |
|
| 441 | - } |
|
| 442 | - $target[$_] = trim($target[$_]); |
|
| 443 | - if(!empty($target[$_])) { |
|
| 444 | - $href = '[~' . $target[$_] . '~]'; |
|
| 445 | - } |
|
| 446 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 447 | - } |
|
| 448 | - $c++; |
|
| 449 | - } |
|
| 450 | - $content = implode('', $array); |
|
| 451 | - $f['content'] = $modx->db->escape($content); |
|
| 452 | - $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 453 | - } |
|
| 397 | + global $modx; |
|
| 398 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 399 | + |
|
| 400 | + $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 401 | + while($row = $modx->db->getRow($rs)) { |
|
| 402 | + $id = $row['id']; |
|
| 403 | + $array = explode('<a href=', $row['content']); |
|
| 404 | + $c = 0; |
|
| 405 | + foreach($array as $v) { |
|
| 406 | + if($v[0] === '"') { |
|
| 407 | + $v = substr($v, 1); |
|
| 408 | + list($href, $v) = explode('"', $v, 2); |
|
| 409 | + $_ = $href; |
|
| 410 | + if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 411 | + $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 412 | + } |
|
| 413 | + if($_[0] === '/') { |
|
| 414 | + $_ = substr($_, 1); |
|
| 415 | + } |
|
| 416 | + $_ = str_replace('/index.html', '.html', $_); |
|
| 417 | + $level = substr_count($_, '../'); |
|
| 418 | + if(1 < $level) { |
|
| 419 | + if(!isset($p[$id])) { |
|
| 420 | + $p[$id] = $modx->getParentIds($id); |
|
| 421 | + } |
|
| 422 | + $k = array_keys($p[$id]); |
|
| 423 | + while(0 < $level) { |
|
| 424 | + $dir = array_shift($k); |
|
| 425 | + $level--; |
|
| 426 | + } |
|
| 427 | + if($dir != '') { |
|
| 428 | + $dir .= '/'; |
|
| 429 | + } |
|
| 430 | + } else { |
|
| 431 | + $dir = ''; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + $_ = trim($_, './'); |
|
| 435 | + if(strpos($_, '/') !== false) { |
|
| 436 | + $_ = substr($_, strrpos($_, '/')); |
|
| 437 | + } |
|
| 438 | + $_ = $dir . str_replace('.html', '', $_); |
|
| 439 | + if(!isset($target[$_])) { |
|
| 440 | + $target[$_] = $modx->getIdFromAlias($_); |
|
| 441 | + } |
|
| 442 | + $target[$_] = trim($target[$_]); |
|
| 443 | + if(!empty($target[$_])) { |
|
| 444 | + $href = '[~' . $target[$_] . '~]'; |
|
| 445 | + } |
|
| 446 | + $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 447 | + } |
|
| 448 | + $c++; |
|
| 449 | + } |
|
| 450 | + $content = implode('', $array); |
|
| 451 | + $f['content'] = $modx->db->escape($content); |
|
| 452 | + $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 453 | + } |
|
| 454 | 454 | } |