@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | |
@@ -58,13 +58,15 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // get base path and url |
| 60 | 60 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
| 61 | -if (count($a) > 1) |
|
| 61 | +if (count($a) > 1) { |
|
| 62 | 62 | array_pop($a); |
| 63 | +} |
|
| 63 | 64 | $url = implode("install", $a); |
| 64 | 65 | reset($a); |
| 65 | 66 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
| 66 | -if (count($a) > 1) |
|
| 67 | +if (count($a) > 1) { |
|
| 67 | 68 | array_pop($a); |
| 69 | +} |
|
| 68 | 70 | $pth = implode("install", $a); |
| 69 | 71 | unset ($a); |
| 70 | 72 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 86 | 88 | $create = true; |
| 87 | 89 | } else { |
| 88 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 90 | + if (function_exists('mysqli_set_charset')) { |
|
| 91 | + mysqli_set_charset($conn, $database_charset); |
|
| 92 | + } |
|
| 89 | 93 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 90 | 94 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 91 | 95 | } |
@@ -132,7 +136,8 @@ discard block |
||
| 132 | 136 | * @param string $propertyString |
| 133 | 137 | * @return array |
| 134 | 138 | */ |
| 135 | - function parseProperties($propertyString) { |
|
| 139 | + function parseProperties($propertyString) |
|
| 140 | + { |
|
| 136 | 141 | $parameter= array (); |
| 137 | 142 | if (!empty ($propertyString)) { |
| 138 | 143 | $tmpParams= explode("&", $propertyString); |
@@ -141,11 +146,14 @@ discard block |
||
| 141 | 146 | if (strpos($tmpParams[$x], '=', 0)) { |
| 142 | 147 | $pTmp= explode("=", $tmpParams[$x]); |
| 143 | 148 | $pvTmp= explode(";", trim($pTmp[1])); |
| 144 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
| 145 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 149 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
| 150 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
| 151 | + } |
|
| 152 | + //list default |
|
| 146 | 153 | else |
| 147 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
| 148 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 154 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
| 155 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 156 | + } |
|
| 149 | 157 | } |
| 150 | 158 | } |
| 151 | 159 | } |
@@ -216,7 +224,7 @@ discard block |
||
| 216 | 224 | // custom or not |
| 217 | 225 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 218 | 226 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 219 | -}else{ |
|
| 227 | +} else { |
|
| 220 | 228 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 221 | 229 | } |
| 222 | 230 | |
@@ -352,7 +360,9 @@ discard block |
||
| 352 | 360 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 353 | 361 | return; |
| 354 | 362 | } |
| 355 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 363 | + if(!is_null($save_sql_id_as)) { |
|
| 364 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 365 | + } |
|
| 356 | 366 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
| 357 | 367 | } |
| 358 | 368 | } |
@@ -446,9 +456,9 @@ discard block |
||
| 446 | 456 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
| 447 | 457 | $filecontent = $moduleChunk[2]; |
| 448 | 458 | |
| 449 | - if (!file_exists($filecontent)) |
|
| 450 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 451 | - else { |
|
| 459 | + if (!file_exists($filecontent)) { |
|
| 460 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 461 | + } else { |
|
| 452 | 462 | |
| 453 | 463 | // Create the category if it does not already exist |
| 454 | 464 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -500,9 +510,9 @@ discard block |
||
| 500 | 510 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 501 | 511 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 502 | 512 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 503 | - if (!file_exists($filecontent)) |
|
| 504 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 505 | - else { |
|
| 513 | + if (!file_exists($filecontent)) { |
|
| 514 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 515 | + } else { |
|
| 506 | 516 | |
| 507 | 517 | // Create the category if it does not already exist |
| 508 | 518 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -552,9 +562,9 @@ discard block |
||
| 552 | 562 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 553 | 563 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
| 554 | 564 | } |
| 555 | - if (!file_exists($filecontent)) |
|
| 556 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 557 | - else { |
|
| 565 | + if (!file_exists($filecontent)) { |
|
| 566 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 567 | + } else { |
|
| 558 | 568 | |
| 559 | 569 | // disable legacy versions based on legacy_names provided |
| 560 | 570 | if(!empty($leg_names)) { |
@@ -573,7 +583,7 @@ discard block |
||
| 573 | 583 | $insert = true; |
| 574 | 584 | while($row = mysqli_fetch_assoc($rs)) { |
| 575 | 585 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 576 | - if($row['description'] == $desc){ |
|
| 586 | + if($row['description'] == $desc) { |
|
| 577 | 587 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
| 578 | 588 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 579 | 589 | return; |
@@ -631,9 +641,9 @@ discard block |
||
| 631 | 641 | $filecontent = $moduleSnippet[2]; |
| 632 | 642 | $properties = $moduleSnippet[3]; |
| 633 | 643 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 634 | - if (!file_exists($filecontent)) |
|
| 635 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 636 | - else { |
|
| 644 | + if (!file_exists($filecontent)) { |
|
| 645 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 646 | + } else { |
|
| 637 | 647 | |
| 638 | 648 | // Create the category if it does not already exist |
| 639 | 649 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -741,13 +751,16 @@ discard block |
||
| 741 | 751 | } |
| 742 | 752 | |
| 743 | 753 | // call back function |
| 744 | -if ($callBackFnc != "") |
|
| 754 | +if ($callBackFnc != "") { |
|
| 745 | 755 | $callBackFnc ($sqlParser); |
| 756 | +} |
|
| 746 | 757 | |
| 747 | 758 | // Setup the MODX API -- needed for the cache processor |
| 748 | 759 | define('MODX_API_MODE', true); |
| 749 | 760 | define('MODX_BASE_PATH', $base_path); |
| 750 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 761 | +if (!defined('MODX_MANAGER_PATH')) { |
|
| 762 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 763 | +} |
|
| 751 | 764 | $database_type = 'mysqli'; |
| 752 | 765 | // initiate a new document parser |
| 753 | 766 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -792,11 +805,12 @@ discard block |
||
| 792 | 805 | * @param string $old |
| 793 | 806 | * @return string |
| 794 | 807 | */ |
| 795 | -function propUpdate($new,$old){ |
|
| 808 | +function propUpdate($new,$old) |
|
| 809 | +{ |
|
| 796 | 810 | $newArr = parseProperties($new); |
| 797 | 811 | $oldArr = parseProperties($old); |
| 798 | - foreach ($oldArr as $k => $v){ |
|
| 799 | - if (isset($v['0']['options'])){ |
|
| 812 | + foreach ($oldArr as $k => $v) { |
|
| 813 | + if (isset($v['0']['options'])) { |
|
| 800 | 814 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 801 | 815 | } |
| 802 | 816 | } |
@@ -811,12 +825,17 @@ discard block |
||
| 811 | 825 | * @param bool|mixed $json |
| 812 | 826 | * @return string |
| 813 | 827 | */ |
| 814 | -function parseProperties($propertyString, $json=false) { |
|
| 828 | +function parseProperties($propertyString, $json=false) |
|
| 829 | +{ |
|
| 815 | 830 | $propertyString = str_replace('{}', '', $propertyString ); |
| 816 | 831 | $propertyString = str_replace('} {', ',', $propertyString ); |
| 817 | 832 | |
| 818 | - if(empty($propertyString)) return array(); |
|
| 819 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 833 | + if(empty($propertyString)) { |
|
| 834 | + return array(); |
|
| 835 | + } |
|
| 836 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
| 837 | + return array(); |
|
| 838 | + } |
|
| 820 | 839 | |
| 821 | 840 | $jsonFormat = isJson($propertyString, true); |
| 822 | 841 | $property = array(); |
@@ -858,7 +877,7 @@ discard block |
||
| 858 | 877 | |
| 859 | 878 | } |
| 860 | 879 | // new json-format |
| 861 | - } else if(!empty($jsonFormat)){ |
|
| 880 | + } else if(!empty($jsonFormat)) { |
|
| 862 | 881 | $property = $jsonFormat; |
| 863 | 882 | } |
| 864 | 883 | if ($json) { |
@@ -873,7 +892,8 @@ discard block |
||
| 873 | 892 | * @param bool $returnData |
| 874 | 893 | * @return bool|mixed |
| 875 | 894 | */ |
| 876 | -function isJson($string, $returnData=false) { |
|
| 895 | +function isJson($string, $returnData=false) |
|
| 896 | +{ |
|
| 877 | 897 | $data = json_decode($string, true); |
| 878 | 898 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 879 | 899 | } |
@@ -883,7 +903,8 @@ discard block |
||
| 883 | 903 | * @param SqlParser $sqlParser |
| 884 | 904 | * @return int |
| 885 | 905 | */ |
| 886 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 906 | +function getCreateDbCategory($category, $sqlParser) |
|
| 907 | +{ |
|
| 887 | 908 | $dbase = $sqlParser->dbname; |
| 888 | 909 | $dbase = '`' . trim($dbase,'`') . '`'; |
| 889 | 910 | $table_prefix = $sqlParser->prefix; |
@@ -911,7 +932,8 @@ discard block |
||
| 911 | 932 | * @param string $type |
| 912 | 933 | * @return string |
| 913 | 934 | */ |
| 914 | -function removeDocblock($code, $type) { |
|
| 935 | +function removeDocblock($code, $type) |
|
| 936 | +{ |
|
| 915 | 937 | |
| 916 | 938 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 917 | 939 | |
@@ -932,8 +954,9 @@ discard block |
||
| 932 | 954 | default: |
| 933 | 955 | return $cleaned; |
| 934 | 956 | }; |
| 935 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 936 | - return $cleaned; |
|
| 957 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
| 958 | + return $cleaned; |
|
| 959 | + } |
|
| 937 | 960 | |
| 938 | 961 | // fileBinding not found - return code incl docblock |
| 939 | 962 | return $code; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | 5 | header("X-XSS-Protection: 0");
|
@@ -11,22 +11,22 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; |
| 13 | 13 | |
| 14 | -if (!isset($modx->config['manager_menu_height'])) {
|
|
| 14 | +if (!isset($modx->config['manager_menu_height'])) { |
|
| 15 | 15 | $modx->config['manager_menu_height'] = 2.2; // rem |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if (!isset($modx->config['manager_tree_width'])) {
|
|
| 18 | +if (!isset($modx->config['manager_tree_width'])) { |
|
| 19 | 19 | $modx->config['manager_tree_width'] = 20; // rem |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
|
|
| 22 | +if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) { |
|
| 23 | 23 | $initMainframeAction = $_SESSION['onLoginForwardToAction']; |
| 24 | 24 | unset($_SESSION['onLoginForwardToAction']); |
| 25 | -} else {
|
|
| 25 | +} else { |
|
| 26 | 26 | $initMainframeAction = 2; // welcome.static |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if (!isset($_SESSION['tree_show_only_folders'])) {
|
|
| 29 | +if (!isset($_SESSION['tree_show_only_folders'])) { |
|
| 30 | 30 | $_SESSION['tree_show_only_folders'] = 0; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -35,21 +35,21 @@ discard block |
||
| 35 | 35 | $tree_width = $modx->config['manager_tree_width']; |
| 36 | 36 | $tree_min_width = 0; |
| 37 | 37 | |
| 38 | -if (isset($_COOKIE['MODX_widthSideBar'])) {
|
|
| 38 | +if (isset($_COOKIE['MODX_widthSideBar'])) { |
|
| 39 | 39 | $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar']; |
| 40 | -} else {
|
|
| 40 | +} else { |
|
| 41 | 41 | $MODX_widthSideBar = $tree_width; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -if (!$MODX_widthSideBar) {
|
|
| 44 | +if (!$MODX_widthSideBar) { |
|
| 45 | 45 | $body_class .= 'sidebar-closed'; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -if (isset($_COOKIE['MODX_themeColor'])) {
|
|
| 48 | +if (isset($_COOKIE['MODX_themeColor'])) { |
|
| 49 | 49 | $body_class .= ' ' . $_COOKIE['MODX_themeColor']; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -if (isset($modx->pluginCache['ElementsInTree'])) {
|
|
| 52 | +if (isset($modx->pluginCache['ElementsInTree'])) { |
|
| 53 | 53 | $body_class .= ' ElementsInTree'; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | 'type8' => $_lang["lock_element_type_8"] |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | -foreach ($unlockTranslations as $key => $value) {
|
|
| 68 | +foreach ($unlockTranslations as $key => $value) { |
|
| 69 | 69 | $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $user = $modx->getUserInfo($modx->getLoginUserID()); |
| 73 | -if ($user['which_browser'] == 'default') {
|
|
| 73 | +if ($user['which_browser'] == 'default') { |
|
| 74 | 74 | $user['which_browser'] = $modx->config['which_browser']; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime; |
| 78 | 78 | |
| 79 | -if ($modx->config['manager_theme'] == 'default') {
|
|
| 80 | - if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
|
|
| 79 | +if ($modx->config['manager_theme'] == 'default') { |
|
| 80 | + if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
| 81 | 81 | require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php'; |
| 82 | 82 | $minifier = new Formatter\CSSMinify(); |
| 83 | 83 | $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css'); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $css = $minifier->minify(); |
| 95 | 95 | file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css); |
| 96 | 96 | } |
| 97 | - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
|
|
| 97 | + if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
| 98 | 98 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | <?php |
| 249 | 249 | // invoke OnManagerTopPrerender event |
| 250 | 250 | $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST);
|
| 251 | - if (is_array($evtOut)) {
|
|
| 251 | + if (is_array($evtOut)) { |
|
| 252 | 252 | echo implode("\n", $evtOut);
|
| 253 | 253 | } |
| 254 | 254 | ?> |
@@ -419,9 +419,12 @@ discard block |
||
| 419 | 419 | <div id="evo-tab-page-home" class="evo-tab-page show"> |
| 420 | 420 | <iframe id="mainframe" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe> |
| 421 | 421 | </div> |
| 422 | - <?php else: ?> |
|
| 422 | + <?php else { |
|
| 423 | + : ?> |
|
| 423 | 424 | <iframe id="mainframe" name="main" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe> |
| 424 | - <?php endif; ?> |
|
| 425 | + <?php endif; |
|
| 426 | +} |
|
| 427 | +?> |
|
| 425 | 428 | <div id="mainloader"></div> |
| 426 | 429 | </div> |
| 427 | 430 | <div id="resizer"></div> |
@@ -434,11 +437,11 @@ discard block |
||
| 434 | 437 | 'tree_sortdir', |
| 435 | 438 | 'tree_nodename' |
| 436 | 439 | ); |
| 437 | - foreach ($sortParams as $param) {
|
|
| 438 | - if (isset($_REQUEST[$param])) {
|
|
| 440 | + foreach ($sortParams as $param) { |
|
| 441 | + if (isset($_REQUEST[$param])) { |
|
| 439 | 442 | $modx->manager->saveLastUserSetting($param, $_REQUEST[$param]); |
| 440 | 443 | $_SESSION[$param] = $_REQUEST[$param]; |
| 441 | - } else if (!isset($_SESSION[$param])) {
|
|
| 444 | + } else if (!isset($_SESSION[$param])) { |
|
| 442 | 445 | $_SESSION[$param] = $modx->manager->getLastUserSetting($param); |
| 443 | 446 | } |
| 444 | 447 | } |
@@ -524,9 +527,9 @@ discard block |
||
| 524 | 527 | * @param string $text |
| 525 | 528 | * @param bool $allowed |
| 526 | 529 | */ |
| 527 | - function constructLink($action, $img, $text, $allowed) |
|
| 528 | - {
|
|
| 529 | - if ((bool)$allowed) {
|
|
| 530 | + function constructLink($action, $img, $text, $allowed) |
|
| 531 | + { |
|
| 532 | + if ((bool)$allowed) { |
|
| 530 | 533 | echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action);
|
| 531 | 534 | echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
|
| 532 | 535 | } |
@@ -631,7 +634,7 @@ discard block |
||
| 631 | 634 | ?> |
| 632 | 635 | |
| 633 | 636 | </div> |
| 634 | -<?php if ($modx->config['show_picker'] != "0") {
|
|
| 637 | +<?php if ($modx->config['show_picker'] != "0") { |
|
| 635 | 638 | include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
|
| 636 | 639 | } ?> |
| 637 | 640 | </body> |
@@ -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,443 +12,443 @@ discard block |
||
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | 14 | function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
| 15 | - global $modx; |
|
| 16 | - global $icons, $iconsPrivate, $_style; |
|
| 17 | - global $_lang, $opened, $opened2, $closed2; //added global vars |
|
| 18 | - global $modx_textdir; |
|
| 19 | - |
|
| 20 | - $output = ''; |
|
| 21 | - |
|
| 22 | - // setup spacer |
|
| 23 | - $level = 0; |
|
| 24 | - $spacer = '<span class="indent">'; |
|
| 25 | - for($i = 2; $i <= $indent; $i++) { |
|
| 26 | - $spacer .= '<i></i>'; |
|
| 27 | - $level++; |
|
| 28 | - } |
|
| 29 | - $spacer .= '</span>'; |
|
| 30 | - |
|
| 31 | - // manage order-by |
|
| 32 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 33 | - // This is the first startup, set default sort order |
|
| 34 | - $_SESSION['tree_sortby'] = 'menuindex'; |
|
| 35 | - $_SESSION['tree_sortdir'] = 'ASC'; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - switch($_SESSION['tree_sortby']) { |
|
| 39 | - case 'createdon': |
|
| 40 | - case 'editedon': |
|
| 41 | - case 'publishedon': |
|
| 42 | - case 'pub_date': |
|
| 43 | - case 'unpub_date': |
|
| 44 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 45 | - break; |
|
| 46 | - default: |
|
| 47 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 48 | - }; |
|
| 49 | - |
|
| 50 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 51 | - |
|
| 52 | - // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
| 53 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 54 | - $orderby .= ', menuindex ASC, pagetitle'; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $tblsc = $modx->getFullTableName('site_content'); |
|
| 58 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
| 59 | - $tblst = $modx->getFullTableName('site_templates'); |
|
| 60 | - // get document groups for current user |
|
| 61 | - $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
| 62 | - $showProtected = false; |
|
| 63 | - if(isset ($modx->config['tree_show_protected'])) { |
|
| 64 | - $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 65 | - } |
|
| 66 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 67 | - if($showProtected == false) { |
|
| 68 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 69 | - } else { |
|
| 70 | - $access = ''; |
|
| 71 | - } |
|
| 72 | - $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
| 73 | - $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
| 15 | + global $modx; |
|
| 16 | + global $icons, $iconsPrivate, $_style; |
|
| 17 | + global $_lang, $opened, $opened2, $closed2; //added global vars |
|
| 18 | + global $modx_textdir; |
|
| 19 | + |
|
| 20 | + $output = ''; |
|
| 21 | + |
|
| 22 | + // setup spacer |
|
| 23 | + $level = 0; |
|
| 24 | + $spacer = '<span class="indent">'; |
|
| 25 | + for($i = 2; $i <= $indent; $i++) { |
|
| 26 | + $spacer .= '<i></i>'; |
|
| 27 | + $level++; |
|
| 28 | + } |
|
| 29 | + $spacer .= '</span>'; |
|
| 30 | + |
|
| 31 | + // manage order-by |
|
| 32 | + if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
| 33 | + // This is the first startup, set default sort order |
|
| 34 | + $_SESSION['tree_sortby'] = 'menuindex'; |
|
| 35 | + $_SESSION['tree_sortdir'] = 'ASC'; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + switch($_SESSION['tree_sortby']) { |
|
| 39 | + case 'createdon': |
|
| 40 | + case 'editedon': |
|
| 41 | + case 'publishedon': |
|
| 42 | + case 'pub_date': |
|
| 43 | + case 'unpub_date': |
|
| 44 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 45 | + break; |
|
| 46 | + default: |
|
| 47 | + $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 48 | + }; |
|
| 49 | + |
|
| 50 | + $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 51 | + |
|
| 52 | + // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
| 53 | + if($_SESSION['tree_sortby'] == 'isfolder') { |
|
| 54 | + $orderby .= ', menuindex ASC, pagetitle'; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $tblsc = $modx->getFullTableName('site_content'); |
|
| 58 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
| 59 | + $tblst = $modx->getFullTableName('site_templates'); |
|
| 60 | + // get document groups for current user |
|
| 61 | + $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
| 62 | + $showProtected = false; |
|
| 63 | + if(isset ($modx->config['tree_show_protected'])) { |
|
| 64 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 65 | + } |
|
| 66 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 67 | + if($showProtected == false) { |
|
| 68 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 69 | + } else { |
|
| 70 | + $access = ''; |
|
| 71 | + } |
|
| 72 | + $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
| 73 | + $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
| 74 | 74 | MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles"; |
| 75 | - $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
| 76 | - $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
| 77 | - $result = $modx->db->select($field, $from, $where, $orderby); |
|
| 78 | - if($modx->db->getRecordCount($result) == 0) { |
|
| 79 | - $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
| 83 | - |
|
| 84 | - while($row = $modx->db->getRow($result)) { |
|
| 85 | - $node = ''; |
|
| 86 | - |
|
| 87 | - $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
| 88 | - $nodetitleDisplay = $nodetitle; |
|
| 89 | - |
|
| 90 | - $treeNodeClass = 'node'; |
|
| 91 | - $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
| 92 | - |
|
| 93 | - if($row['deleted'] == 1) { |
|
| 94 | - $treeNodeClass .= ' deleted'; |
|
| 95 | - //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
| 96 | - } elseif($row['published'] == 0) { |
|
| 97 | - $treeNodeClass .= ' unpublished'; |
|
| 98 | - //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
| 99 | - } elseif($row['hidemenu'] == 1) { |
|
| 100 | - $treeNodeClass .= ' hidemenu'; |
|
| 101 | - //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 102 | - } else { |
|
| 103 | - //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - if($row['id'] == $hereid) { |
|
| 107 | - $treeNodeClass .= ' current'; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
| 111 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 112 | - |
|
| 113 | - // Prepare displaying user-locks |
|
| 114 | - $lockedByUser = ''; |
|
| 115 | - $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
| 116 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 117 | - if($rowLock['sid'] == $modx->sid) { |
|
| 118 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 119 | - 'element_type' => $_lang["lock_element_type_7"], |
|
| 120 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 121 | - )); |
|
| 122 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 123 | - } else { |
|
| 124 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 125 | - 'element_type' => $_lang["lock_element_type_7"], |
|
| 126 | - 'username' => $rowLock['username'], |
|
| 127 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 128 | - )); |
|
| 129 | - if($modx->hasPermission('remove_locks')) { |
|
| 130 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 131 | - } else { |
|
| 132 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $url = $modx->makeUrl($row['id']); |
|
| 138 | - |
|
| 139 | - $title = ''; |
|
| 140 | - if(isDateNode($nodeNameSource)) { |
|
| 141 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 142 | - } |
|
| 143 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 145 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 146 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 147 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 148 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 149 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 150 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 152 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 154 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 155 | - $title = $modx->htmlspecialchars($title); |
|
| 156 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 157 | - |
|
| 158 | - $data = array( |
|
| 159 | - 'id' => $row['id'], |
|
| 160 | - 'pagetitle' => $row['pagetitle'], |
|
| 161 | - 'longtitle' => $row['longtitle'], |
|
| 162 | - 'menutitle' => $row['menutitle'], |
|
| 163 | - 'parent' => $parent, |
|
| 164 | - 'isfolder' => $row['isfolder'], |
|
| 165 | - 'published' => $row['published'], |
|
| 166 | - 'deleted' => $row['deleted'], |
|
| 167 | - 'type' => $row['type'], |
|
| 168 | - 'menuindex' => $row['menuindex'], |
|
| 169 | - 'donthit' => $row['donthit'], |
|
| 170 | - 'hidemenu' => $row['hidemenu'], |
|
| 171 | - 'alias' => $row['alias'], |
|
| 172 | - 'contenttype' => $row['contentType'], |
|
| 173 | - 'privateweb' => $row['privateweb'], |
|
| 174 | - 'privatemgr' => $row['privatemgr'], |
|
| 175 | - 'hasAccess' => $row['hasAccess'], |
|
| 176 | - 'template' => $row['template'], |
|
| 177 | - 'nodetitle' => $nodetitle, |
|
| 178 | - 'url' => $url, |
|
| 179 | - 'title' => $title, |
|
| 180 | - 'nodetitleDisplay' => $nodetitleDisplay, |
|
| 181 | - 'weblinkDisplay' => $weblinkDisplay, |
|
| 182 | - 'pageIdDisplay' => $pageIdDisplay, |
|
| 183 | - 'lockedByUser' => $lockedByUser, |
|
| 184 | - 'treeNodeClass' => $treeNodeClass, |
|
| 185 | - 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
| 186 | - 'tree_page_click' => $modx->config['tree_page_click'], |
|
| 187 | - 'showChildren' => 1, |
|
| 188 | - 'openFolder' => 1, |
|
| 189 | - 'contextmenu' => '', |
|
| 190 | - 'tree_minusnode' => $_style['tree_minusnode'], |
|
| 191 | - 'tree_plusnode' => $_style['tree_plusnode'], |
|
| 192 | - 'spacer' => $spacer, |
|
| 193 | - 'subMenuState' => '', |
|
| 194 | - 'level' => $level, |
|
| 195 | - 'isPrivate' => 0, |
|
| 196 | - 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
| 197 | - ); |
|
| 198 | - |
|
| 199 | - $ph = $data; |
|
| 200 | - $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
| 201 | - $ph['indent'] = $indent + 1; |
|
| 202 | - $ph['expandAll'] = $expandAll; |
|
| 203 | - $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
| 204 | - |
|
| 205 | - if(!$row['isfolder']) { |
|
| 206 | - $tpl = getTplSingleNode(); |
|
| 207 | - switch($row['id']) { |
|
| 208 | - case $modx->config['site_start'] : |
|
| 209 | - $icon = $_style['tree_page_home']; |
|
| 210 | - break; |
|
| 211 | - case $modx->config['error_page'] : |
|
| 212 | - $icon = $_style['tree_page_404']; |
|
| 213 | - break; |
|
| 214 | - case $modx->config['site_unavailable_page'] : |
|
| 215 | - $icon = $_style['tree_page_hourglass']; |
|
| 216 | - break; |
|
| 217 | - case $modx->config['unauthorized_page'] : |
|
| 218 | - $icon = $_style['tree_page_info']; |
|
| 219 | - break; |
|
| 220 | - default: |
|
| 221 | - if(isset($icons[$row['contentType']])) { |
|
| 222 | - $icon = $icons[$row['contentType']]; |
|
| 223 | - } else { |
|
| 224 | - $icon = $_style['tree_page']; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - $ph['icon'] = $icon; |
|
| 228 | - |
|
| 229 | - // invoke OnManagerNodePrerender event |
|
| 230 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
| 231 | - if(is_array($prenode)) { |
|
| 232 | - $phnew = array(); |
|
| 233 | - foreach($prenode as $pnode) { |
|
| 234 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 235 | - } |
|
| 236 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - if($ph['contextmenu']) { |
|
| 240 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - if($_SESSION['tree_show_only_folders']) { |
|
| 244 | - if($row['parent'] == 0) { |
|
| 245 | - $node .= $modx->parseText($tpl, $ph); |
|
| 246 | - } else { |
|
| 247 | - $node .= ''; |
|
| 248 | - } |
|
| 249 | - } else { |
|
| 250 | - $node .= $modx->parseText($tpl, $ph); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - } else { |
|
| 254 | - $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
| 255 | - $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
| 256 | - |
|
| 257 | - if($_SESSION['tree_show_only_folders']) { |
|
| 258 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 259 | - $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
| 260 | - $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
| 261 | - $ph['tree_page_click'] = 3; |
|
| 262 | - |
|
| 263 | - // expandAll: two type for partial expansion |
|
| 264 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 265 | - if($expandAll == 1) { |
|
| 266 | - $opened2[] = $row['id']; |
|
| 267 | - } |
|
| 268 | - $ph['icon'] = $ph['icon_folder_open']; |
|
| 269 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 270 | - $ph['node_toggle'] = 1; |
|
| 271 | - $ph['subMenuState'] = ' open'; |
|
| 272 | - |
|
| 273 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 274 | - $ph['showChildren'] = 1; |
|
| 275 | - $ph['icon_node_toggle'] = ''; |
|
| 276 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 277 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 278 | - $ph['showChildren'] = 0; |
|
| 279 | - $ph['openFolder'] = 2; |
|
| 280 | - } else { |
|
| 281 | - $ph['openFolder'] = 2; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - // invoke OnManagerNodePrerender event |
|
| 285 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 286 | - 'ph' => $ph, |
|
| 287 | - 'opened' => '1' |
|
| 288 | - )); |
|
| 289 | - if(is_array($prenode)) { |
|
| 290 | - $phnew = array(); |
|
| 291 | - foreach($prenode as $pnode) { |
|
| 292 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 293 | - } |
|
| 294 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - if($ph['contextmenu']) { |
|
| 298 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $node .= $modx->parseText($tpl, $ph); |
|
| 302 | - if($checkFolders) { |
|
| 303 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 304 | - } |
|
| 305 | - $node .= '</div></div>'; |
|
| 306 | - } else { |
|
| 307 | - $closed2[] = $row['id']; |
|
| 308 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 309 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 310 | - $ph['node_toggle'] = 0; |
|
| 311 | - |
|
| 312 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 313 | - $ph['showChildren'] = 1; |
|
| 314 | - $ph['icon_node_toggle'] = ''; |
|
| 315 | - } elseif(!$checkDocs && $checkFolders) { |
|
| 316 | - $ph['showChildren'] = 0; |
|
| 317 | - $ph['openFolder'] = 2; |
|
| 318 | - } else { |
|
| 319 | - $ph['openFolder'] = 2; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - // invoke OnManagerNodePrerender event |
|
| 323 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 324 | - 'ph' => $ph, |
|
| 325 | - 'opened' => '0' |
|
| 326 | - )); |
|
| 327 | - if(is_array($prenode)) { |
|
| 328 | - $phnew = array(); |
|
| 329 | - foreach($prenode as $pnode) { |
|
| 330 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 331 | - } |
|
| 332 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - if($ph['contextmenu']) { |
|
| 336 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - $node .= $modx->parseText($tpl, $ph); |
|
| 340 | - $node .= '</div></div>'; |
|
| 341 | - } |
|
| 342 | - } else { |
|
| 343 | - $tpl = getTplFolderNode(); |
|
| 344 | - // expandAll: two type for partial expansion |
|
| 345 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 346 | - if($expandAll == 1) { |
|
| 347 | - $opened2[] = $row['id']; |
|
| 348 | - } |
|
| 349 | - $ph['icon'] = $ph['icon_folder_open']; |
|
| 350 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 351 | - $ph['node_toggle'] = 1; |
|
| 352 | - $ph['subMenuState'] = ' open'; |
|
| 353 | - |
|
| 354 | - if($ph['donthit'] == 1) { |
|
| 355 | - $ph['tree_page_click'] = 3; |
|
| 356 | - $ph['icon_node_toggle'] = ''; |
|
| 357 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 358 | - $ph['showChildren'] = 0; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - // invoke OnManagerNodePrerender event |
|
| 362 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 363 | - 'ph' => $ph, |
|
| 364 | - 'opened' => '1' |
|
| 365 | - )); |
|
| 366 | - if(is_array($prenode)) { |
|
| 367 | - $phnew = array(); |
|
| 368 | - foreach($prenode as $pnode) { |
|
| 369 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 370 | - } |
|
| 371 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 372 | - if($ph['showChildren'] == 0) { |
|
| 373 | - unset($opened2[$row['id']]); |
|
| 374 | - $ph['node_toggle'] = 0; |
|
| 375 | - $ph['subMenuState'] = ''; |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - if($ph['showChildren'] == 0) { |
|
| 380 | - $ph['icon_node_toggle'] = ''; |
|
| 381 | - $ph['donthit'] = 1; |
|
| 382 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 383 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if($ph['contextmenu']) { |
|
| 387 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - $node .= $modx->parseText($tpl, $ph); |
|
| 391 | - if($ph['donthit'] == 0) { |
|
| 392 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 393 | - } |
|
| 394 | - $node .= '</div></div>'; |
|
| 395 | - } else { |
|
| 396 | - $closed2[] = $row['id']; |
|
| 397 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 398 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 399 | - $ph['node_toggle'] = 0; |
|
| 400 | - |
|
| 401 | - if($ph['donthit'] == 1) { |
|
| 402 | - $ph['tree_page_click'] = 3; |
|
| 403 | - $ph['icon_node_toggle'] = ''; |
|
| 404 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 405 | - $ph['showChildren'] = 0; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - // invoke OnManagerNodePrerender event |
|
| 409 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 410 | - 'ph' => $ph, |
|
| 411 | - 'opened' => '0' |
|
| 412 | - )); |
|
| 413 | - if(is_array($prenode)) { |
|
| 414 | - $phnew = array(); |
|
| 415 | - foreach($prenode as $pnode) { |
|
| 416 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 417 | - } |
|
| 418 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - if($ph['showChildren'] == 0) { |
|
| 422 | - $ph['icon_node_toggle'] = ''; |
|
| 423 | - $ph['donthit'] = 1; |
|
| 424 | - $ph['icon'] = $ph['icon_folder_close']; |
|
| 425 | - $tpl = getTplFolderNodeNotChildren(); |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - if($ph['contextmenu']) { |
|
| 429 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - $node .= $modx->parseText($tpl, $ph); |
|
| 433 | - $node .= '</div></div>'; |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - // invoke OnManagerNodeRender event |
|
| 439 | - $data['node'] = $node; |
|
| 440 | - $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
| 441 | - if(is_array($evtOut)) { |
|
| 442 | - $evtOut = implode("\n", $evtOut); |
|
| 443 | - } |
|
| 444 | - if($evtOut != '') { |
|
| 445 | - $node = trim($evtOut); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $output .= $node; |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return $output; |
|
| 75 | + $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
| 76 | + $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
| 77 | + $result = $modx->db->select($field, $from, $where, $orderby); |
|
| 78 | + if($modx->db->getRecordCount($result) == 0) { |
|
| 79 | + $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
| 83 | + |
|
| 84 | + while($row = $modx->db->getRow($result)) { |
|
| 85 | + $node = ''; |
|
| 86 | + |
|
| 87 | + $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
| 88 | + $nodetitleDisplay = $nodetitle; |
|
| 89 | + |
|
| 90 | + $treeNodeClass = 'node'; |
|
| 91 | + $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
| 92 | + |
|
| 93 | + if($row['deleted'] == 1) { |
|
| 94 | + $treeNodeClass .= ' deleted'; |
|
| 95 | + //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
| 96 | + } elseif($row['published'] == 0) { |
|
| 97 | + $treeNodeClass .= ' unpublished'; |
|
| 98 | + //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
| 99 | + } elseif($row['hidemenu'] == 1) { |
|
| 100 | + $treeNodeClass .= ' hidemenu'; |
|
| 101 | + //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 102 | + } else { |
|
| 103 | + //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + if($row['id'] == $hereid) { |
|
| 107 | + $treeNodeClass .= ' current'; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
| 111 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 112 | + |
|
| 113 | + // Prepare displaying user-locks |
|
| 114 | + $lockedByUser = ''; |
|
| 115 | + $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
| 116 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 117 | + if($rowLock['sid'] == $modx->sid) { |
|
| 118 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 119 | + 'element_type' => $_lang["lock_element_type_7"], |
|
| 120 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 121 | + )); |
|
| 122 | + $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 123 | + } else { |
|
| 124 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 125 | + 'element_type' => $_lang["lock_element_type_7"], |
|
| 126 | + 'username' => $rowLock['username'], |
|
| 127 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 128 | + )); |
|
| 129 | + if($modx->hasPermission('remove_locks')) { |
|
| 130 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 131 | + } else { |
|
| 132 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $url = $modx->makeUrl($row['id']); |
|
| 138 | + |
|
| 139 | + $title = ''; |
|
| 140 | + if(isDateNode($nodeNameSource)) { |
|
| 141 | + $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 142 | + } |
|
| 143 | + $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 144 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 145 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 146 | + $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 147 | + $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 148 | + $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 149 | + $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 150 | + $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 151 | + $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 152 | + $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 153 | + $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 154 | + $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 155 | + $title = $modx->htmlspecialchars($title); |
|
| 156 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 157 | + |
|
| 158 | + $data = array( |
|
| 159 | + 'id' => $row['id'], |
|
| 160 | + 'pagetitle' => $row['pagetitle'], |
|
| 161 | + 'longtitle' => $row['longtitle'], |
|
| 162 | + 'menutitle' => $row['menutitle'], |
|
| 163 | + 'parent' => $parent, |
|
| 164 | + 'isfolder' => $row['isfolder'], |
|
| 165 | + 'published' => $row['published'], |
|
| 166 | + 'deleted' => $row['deleted'], |
|
| 167 | + 'type' => $row['type'], |
|
| 168 | + 'menuindex' => $row['menuindex'], |
|
| 169 | + 'donthit' => $row['donthit'], |
|
| 170 | + 'hidemenu' => $row['hidemenu'], |
|
| 171 | + 'alias' => $row['alias'], |
|
| 172 | + 'contenttype' => $row['contentType'], |
|
| 173 | + 'privateweb' => $row['privateweb'], |
|
| 174 | + 'privatemgr' => $row['privatemgr'], |
|
| 175 | + 'hasAccess' => $row['hasAccess'], |
|
| 176 | + 'template' => $row['template'], |
|
| 177 | + 'nodetitle' => $nodetitle, |
|
| 178 | + 'url' => $url, |
|
| 179 | + 'title' => $title, |
|
| 180 | + 'nodetitleDisplay' => $nodetitleDisplay, |
|
| 181 | + 'weblinkDisplay' => $weblinkDisplay, |
|
| 182 | + 'pageIdDisplay' => $pageIdDisplay, |
|
| 183 | + 'lockedByUser' => $lockedByUser, |
|
| 184 | + 'treeNodeClass' => $treeNodeClass, |
|
| 185 | + 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
| 186 | + 'tree_page_click' => $modx->config['tree_page_click'], |
|
| 187 | + 'showChildren' => 1, |
|
| 188 | + 'openFolder' => 1, |
|
| 189 | + 'contextmenu' => '', |
|
| 190 | + 'tree_minusnode' => $_style['tree_minusnode'], |
|
| 191 | + 'tree_plusnode' => $_style['tree_plusnode'], |
|
| 192 | + 'spacer' => $spacer, |
|
| 193 | + 'subMenuState' => '', |
|
| 194 | + 'level' => $level, |
|
| 195 | + 'isPrivate' => 0, |
|
| 196 | + 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
| 197 | + ); |
|
| 198 | + |
|
| 199 | + $ph = $data; |
|
| 200 | + $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
| 201 | + $ph['indent'] = $indent + 1; |
|
| 202 | + $ph['expandAll'] = $expandAll; |
|
| 203 | + $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
| 204 | + |
|
| 205 | + if(!$row['isfolder']) { |
|
| 206 | + $tpl = getTplSingleNode(); |
|
| 207 | + switch($row['id']) { |
|
| 208 | + case $modx->config['site_start'] : |
|
| 209 | + $icon = $_style['tree_page_home']; |
|
| 210 | + break; |
|
| 211 | + case $modx->config['error_page'] : |
|
| 212 | + $icon = $_style['tree_page_404']; |
|
| 213 | + break; |
|
| 214 | + case $modx->config['site_unavailable_page'] : |
|
| 215 | + $icon = $_style['tree_page_hourglass']; |
|
| 216 | + break; |
|
| 217 | + case $modx->config['unauthorized_page'] : |
|
| 218 | + $icon = $_style['tree_page_info']; |
|
| 219 | + break; |
|
| 220 | + default: |
|
| 221 | + if(isset($icons[$row['contentType']])) { |
|
| 222 | + $icon = $icons[$row['contentType']]; |
|
| 223 | + } else { |
|
| 224 | + $icon = $_style['tree_page']; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + $ph['icon'] = $icon; |
|
| 228 | + |
|
| 229 | + // invoke OnManagerNodePrerender event |
|
| 230 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
| 231 | + if(is_array($prenode)) { |
|
| 232 | + $phnew = array(); |
|
| 233 | + foreach($prenode as $pnode) { |
|
| 234 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 235 | + } |
|
| 236 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + if($ph['contextmenu']) { |
|
| 240 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + if($_SESSION['tree_show_only_folders']) { |
|
| 244 | + if($row['parent'] == 0) { |
|
| 245 | + $node .= $modx->parseText($tpl, $ph); |
|
| 246 | + } else { |
|
| 247 | + $node .= ''; |
|
| 248 | + } |
|
| 249 | + } else { |
|
| 250 | + $node .= $modx->parseText($tpl, $ph); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + } else { |
|
| 254 | + $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
| 255 | + $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
| 256 | + |
|
| 257 | + if($_SESSION['tree_show_only_folders']) { |
|
| 258 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 259 | + $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
| 260 | + $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
| 261 | + $ph['tree_page_click'] = 3; |
|
| 262 | + |
|
| 263 | + // expandAll: two type for partial expansion |
|
| 264 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 265 | + if($expandAll == 1) { |
|
| 266 | + $opened2[] = $row['id']; |
|
| 267 | + } |
|
| 268 | + $ph['icon'] = $ph['icon_folder_open']; |
|
| 269 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 270 | + $ph['node_toggle'] = 1; |
|
| 271 | + $ph['subMenuState'] = ' open'; |
|
| 272 | + |
|
| 273 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 274 | + $ph['showChildren'] = 1; |
|
| 275 | + $ph['icon_node_toggle'] = ''; |
|
| 276 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 277 | + } elseif(!$checkDocs && $checkFolders) { |
|
| 278 | + $ph['showChildren'] = 0; |
|
| 279 | + $ph['openFolder'] = 2; |
|
| 280 | + } else { |
|
| 281 | + $ph['openFolder'] = 2; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + // invoke OnManagerNodePrerender event |
|
| 285 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 286 | + 'ph' => $ph, |
|
| 287 | + 'opened' => '1' |
|
| 288 | + )); |
|
| 289 | + if(is_array($prenode)) { |
|
| 290 | + $phnew = array(); |
|
| 291 | + foreach($prenode as $pnode) { |
|
| 292 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 293 | + } |
|
| 294 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + if($ph['contextmenu']) { |
|
| 298 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $node .= $modx->parseText($tpl, $ph); |
|
| 302 | + if($checkFolders) { |
|
| 303 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 304 | + } |
|
| 305 | + $node .= '</div></div>'; |
|
| 306 | + } else { |
|
| 307 | + $closed2[] = $row['id']; |
|
| 308 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 309 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 310 | + $ph['node_toggle'] = 0; |
|
| 311 | + |
|
| 312 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
| 313 | + $ph['showChildren'] = 1; |
|
| 314 | + $ph['icon_node_toggle'] = ''; |
|
| 315 | + } elseif(!$checkDocs && $checkFolders) { |
|
| 316 | + $ph['showChildren'] = 0; |
|
| 317 | + $ph['openFolder'] = 2; |
|
| 318 | + } else { |
|
| 319 | + $ph['openFolder'] = 2; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + // invoke OnManagerNodePrerender event |
|
| 323 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 324 | + 'ph' => $ph, |
|
| 325 | + 'opened' => '0' |
|
| 326 | + )); |
|
| 327 | + if(is_array($prenode)) { |
|
| 328 | + $phnew = array(); |
|
| 329 | + foreach($prenode as $pnode) { |
|
| 330 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 331 | + } |
|
| 332 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + if($ph['contextmenu']) { |
|
| 336 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + $node .= $modx->parseText($tpl, $ph); |
|
| 340 | + $node .= '</div></div>'; |
|
| 341 | + } |
|
| 342 | + } else { |
|
| 343 | + $tpl = getTplFolderNode(); |
|
| 344 | + // expandAll: two type for partial expansion |
|
| 345 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
| 346 | + if($expandAll == 1) { |
|
| 347 | + $opened2[] = $row['id']; |
|
| 348 | + } |
|
| 349 | + $ph['icon'] = $ph['icon_folder_open']; |
|
| 350 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
| 351 | + $ph['node_toggle'] = 1; |
|
| 352 | + $ph['subMenuState'] = ' open'; |
|
| 353 | + |
|
| 354 | + if($ph['donthit'] == 1) { |
|
| 355 | + $ph['tree_page_click'] = 3; |
|
| 356 | + $ph['icon_node_toggle'] = ''; |
|
| 357 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 358 | + $ph['showChildren'] = 0; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + // invoke OnManagerNodePrerender event |
|
| 362 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 363 | + 'ph' => $ph, |
|
| 364 | + 'opened' => '1' |
|
| 365 | + )); |
|
| 366 | + if(is_array($prenode)) { |
|
| 367 | + $phnew = array(); |
|
| 368 | + foreach($prenode as $pnode) { |
|
| 369 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 370 | + } |
|
| 371 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 372 | + if($ph['showChildren'] == 0) { |
|
| 373 | + unset($opened2[$row['id']]); |
|
| 374 | + $ph['node_toggle'] = 0; |
|
| 375 | + $ph['subMenuState'] = ''; |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + if($ph['showChildren'] == 0) { |
|
| 380 | + $ph['icon_node_toggle'] = ''; |
|
| 381 | + $ph['donthit'] = 1; |
|
| 382 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 383 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if($ph['contextmenu']) { |
|
| 387 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + $node .= $modx->parseText($tpl, $ph); |
|
| 391 | + if($ph['donthit'] == 0) { |
|
| 392 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
| 393 | + } |
|
| 394 | + $node .= '</div></div>'; |
|
| 395 | + } else { |
|
| 396 | + $closed2[] = $row['id']; |
|
| 397 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 398 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
| 399 | + $ph['node_toggle'] = 0; |
|
| 400 | + |
|
| 401 | + if($ph['donthit'] == 1) { |
|
| 402 | + $ph['tree_page_click'] = 3; |
|
| 403 | + $ph['icon_node_toggle'] = ''; |
|
| 404 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 405 | + $ph['showChildren'] = 0; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + // invoke OnManagerNodePrerender event |
|
| 409 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
| 410 | + 'ph' => $ph, |
|
| 411 | + 'opened' => '0' |
|
| 412 | + )); |
|
| 413 | + if(is_array($prenode)) { |
|
| 414 | + $phnew = array(); |
|
| 415 | + foreach($prenode as $pnode) { |
|
| 416 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
| 417 | + } |
|
| 418 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + if($ph['showChildren'] == 0) { |
|
| 422 | + $ph['icon_node_toggle'] = ''; |
|
| 423 | + $ph['donthit'] = 1; |
|
| 424 | + $ph['icon'] = $ph['icon_folder_close']; |
|
| 425 | + $tpl = getTplFolderNodeNotChildren(); |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + if($ph['contextmenu']) { |
|
| 429 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + $node .= $modx->parseText($tpl, $ph); |
|
| 433 | + $node .= '</div></div>'; |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + // invoke OnManagerNodeRender event |
|
| 439 | + $data['node'] = $node; |
|
| 440 | + $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
| 441 | + if(is_array($evtOut)) { |
|
| 442 | + $evtOut = implode("\n", $evtOut); |
|
| 443 | + } |
|
| 444 | + if($evtOut != '') { |
|
| 445 | + $node = trim($evtOut); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $output .= $node; |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return $output; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -456,30 +456,30 @@ discard block |
||
| 456 | 456 | * @return array |
| 457 | 457 | */ |
| 458 | 458 | function getIconInfo($_style) { |
| 459 | - if(!isset($_style['tree_page_gif'])) { |
|
| 460 | - $_style['tree_page_gif'] = $_style['tree_page']; |
|
| 461 | - } |
|
| 462 | - if(!isset($_style['tree_page_jpg'])) { |
|
| 463 | - $_style['tree_page_jpg'] = $_style['tree_page']; |
|
| 464 | - } |
|
| 465 | - if(!isset($_style['tree_page_png'])) { |
|
| 466 | - $_style['tree_page_png'] = $_style['tree_page']; |
|
| 467 | - } |
|
| 468 | - $icons = array( |
|
| 469 | - 'text/html' => $_style['tree_page_html'], |
|
| 470 | - 'text/plain' => $_style['tree_page'], |
|
| 471 | - 'text/xml' => $_style['tree_page_xml'], |
|
| 472 | - 'text/css' => $_style['tree_page_css'], |
|
| 473 | - 'text/javascript' => $_style['tree_page_js'], |
|
| 474 | - 'application/rss+xml' => $_style['tree_page_rss'], |
|
| 475 | - 'application/pdf' => $_style['tree_page_pdf'], |
|
| 476 | - 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
| 477 | - 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
| 478 | - 'image/gif' => $_style['tree_page_gif'], |
|
| 479 | - 'image/jpg' => $_style['tree_page_jpg'], |
|
| 480 | - 'image/png' => $_style['tree_page_png'] |
|
| 481 | - ); |
|
| 482 | - return $icons; |
|
| 459 | + if(!isset($_style['tree_page_gif'])) { |
|
| 460 | + $_style['tree_page_gif'] = $_style['tree_page']; |
|
| 461 | + } |
|
| 462 | + if(!isset($_style['tree_page_jpg'])) { |
|
| 463 | + $_style['tree_page_jpg'] = $_style['tree_page']; |
|
| 464 | + } |
|
| 465 | + if(!isset($_style['tree_page_png'])) { |
|
| 466 | + $_style['tree_page_png'] = $_style['tree_page']; |
|
| 467 | + } |
|
| 468 | + $icons = array( |
|
| 469 | + 'text/html' => $_style['tree_page_html'], |
|
| 470 | + 'text/plain' => $_style['tree_page'], |
|
| 471 | + 'text/xml' => $_style['tree_page_xml'], |
|
| 472 | + 'text/css' => $_style['tree_page_css'], |
|
| 473 | + 'text/javascript' => $_style['tree_page_js'], |
|
| 474 | + 'application/rss+xml' => $_style['tree_page_rss'], |
|
| 475 | + 'application/pdf' => $_style['tree_page_pdf'], |
|
| 476 | + 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
| 477 | + 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
| 478 | + 'image/gif' => $_style['tree_page_gif'], |
|
| 479 | + 'image/jpg' => $_style['tree_page_jpg'], |
|
| 480 | + 'image/png' => $_style['tree_page_png'] |
|
| 481 | + ); |
|
| 482 | + return $icons; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | /** |
@@ -487,30 +487,30 @@ discard block |
||
| 487 | 487 | * @return array |
| 488 | 488 | */ |
| 489 | 489 | function getPrivateIconInfo($_style) { |
| 490 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
| 491 | - $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
| 492 | - } |
|
| 493 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
| 494 | - $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
| 495 | - } |
|
| 496 | - if(!isset($_style['tree_page_png_secure'])) { |
|
| 497 | - $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
| 498 | - } |
|
| 499 | - $iconsPrivate = array( |
|
| 500 | - 'text/html' => $_style['tree_page_html_secure'], |
|
| 501 | - 'text/plain' => $_style['tree_page_secure'], |
|
| 502 | - 'text/xml' => $_style['tree_page_xml_secure'], |
|
| 503 | - 'text/css' => $_style['tree_page_css_secure'], |
|
| 504 | - 'text/javascript' => $_style['tree_page_js_secure'], |
|
| 505 | - 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
| 506 | - 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
| 507 | - 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
| 508 | - 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
| 509 | - 'image/gif' => $_style['tree_page_gif_secure'], |
|
| 510 | - 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
| 511 | - 'image/png' => $_style['tree_page_png_secure'] |
|
| 512 | - ); |
|
| 513 | - return $iconsPrivate; |
|
| 490 | + if(!isset($_style['tree_page_gif_secure'])) { |
|
| 491 | + $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
| 492 | + } |
|
| 493 | + if(!isset($_style['tree_page_jpg_secure'])) { |
|
| 494 | + $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
| 495 | + } |
|
| 496 | + if(!isset($_style['tree_page_png_secure'])) { |
|
| 497 | + $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
| 498 | + } |
|
| 499 | + $iconsPrivate = array( |
|
| 500 | + 'text/html' => $_style['tree_page_html_secure'], |
|
| 501 | + 'text/plain' => $_style['tree_page_secure'], |
|
| 502 | + 'text/xml' => $_style['tree_page_xml_secure'], |
|
| 503 | + 'text/css' => $_style['tree_page_css_secure'], |
|
| 504 | + 'text/javascript' => $_style['tree_page_js_secure'], |
|
| 505 | + 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
| 506 | + 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
| 507 | + 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
| 508 | + 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
| 509 | + 'image/gif' => $_style['tree_page_gif_secure'], |
|
| 510 | + 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
| 511 | + 'image/png' => $_style['tree_page_png_secure'] |
|
| 512 | + ); |
|
| 513 | + return $iconsPrivate; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -519,49 +519,49 @@ discard block |
||
| 519 | 519 | * @return string |
| 520 | 520 | */ |
| 521 | 521 | function getNodeTitle($nodeNameSource, $row) { |
| 522 | - global $modx; |
|
| 523 | - |
|
| 524 | - switch($nodeNameSource) { |
|
| 525 | - case 'menutitle': |
|
| 526 | - $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
| 527 | - break; |
|
| 528 | - case 'alias': |
|
| 529 | - $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
| 530 | - if(strpos($row['alias'], '.') === false) { |
|
| 531 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 532 | - $nodetitle .= $modx->config['friendly_url_suffix']; |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 536 | - break; |
|
| 537 | - case 'pagetitle': |
|
| 538 | - $nodetitle = $row['pagetitle']; |
|
| 539 | - break; |
|
| 540 | - case 'longtitle': |
|
| 541 | - $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
| 542 | - break; |
|
| 543 | - case 'createdon': |
|
| 544 | - case 'editedon': |
|
| 545 | - case 'publishedon': |
|
| 546 | - case 'pub_date': |
|
| 547 | - case 'unpub_date': |
|
| 548 | - $doc = $modx->getDocumentObject('id', $row['id']); |
|
| 549 | - $date = $doc[$nodeNameSource]; |
|
| 550 | - if(!empty($date)) { |
|
| 551 | - $nodetitle = $modx->toDateFormat($date); |
|
| 552 | - } else { |
|
| 553 | - $nodetitle = '- - -'; |
|
| 554 | - } |
|
| 555 | - break; |
|
| 556 | - default: |
|
| 557 | - $nodetitle = $row['pagetitle']; |
|
| 558 | - } |
|
| 559 | - $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
| 560 | - "\r\n", |
|
| 561 | - "\n", |
|
| 562 | - "\r" |
|
| 563 | - ), ' ', $nodetitle), ENT_COMPAT); |
|
| 564 | - return $nodetitle; |
|
| 522 | + global $modx; |
|
| 523 | + |
|
| 524 | + switch($nodeNameSource) { |
|
| 525 | + case 'menutitle': |
|
| 526 | + $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
| 527 | + break; |
|
| 528 | + case 'alias': |
|
| 529 | + $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
| 530 | + if(strpos($row['alias'], '.') === false) { |
|
| 531 | + if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
| 532 | + $nodetitle .= $modx->config['friendly_url_suffix']; |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 536 | + break; |
|
| 537 | + case 'pagetitle': |
|
| 538 | + $nodetitle = $row['pagetitle']; |
|
| 539 | + break; |
|
| 540 | + case 'longtitle': |
|
| 541 | + $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
| 542 | + break; |
|
| 543 | + case 'createdon': |
|
| 544 | + case 'editedon': |
|
| 545 | + case 'publishedon': |
|
| 546 | + case 'pub_date': |
|
| 547 | + case 'unpub_date': |
|
| 548 | + $doc = $modx->getDocumentObject('id', $row['id']); |
|
| 549 | + $date = $doc[$nodeNameSource]; |
|
| 550 | + if(!empty($date)) { |
|
| 551 | + $nodetitle = $modx->toDateFormat($date); |
|
| 552 | + } else { |
|
| 553 | + $nodetitle = '- - -'; |
|
| 554 | + } |
|
| 555 | + break; |
|
| 556 | + default: |
|
| 557 | + $nodetitle = $row['pagetitle']; |
|
| 558 | + } |
|
| 559 | + $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
| 560 | + "\r\n", |
|
| 561 | + "\n", |
|
| 562 | + "\r" |
|
| 563 | + ), ' ', $nodetitle), ENT_COMPAT); |
|
| 564 | + return $nodetitle; |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -569,16 +569,16 @@ discard block |
||
| 569 | 569 | * @return bool |
| 570 | 570 | */ |
| 571 | 571 | function isDateNode($nodeNameSource) { |
| 572 | - switch($nodeNameSource) { |
|
| 573 | - case 'createdon': |
|
| 574 | - case 'editedon': |
|
| 575 | - case 'publishedon': |
|
| 576 | - case 'pub_date': |
|
| 577 | - case 'unpub_date': |
|
| 578 | - return true; |
|
| 579 | - default: |
|
| 580 | - return false; |
|
| 581 | - } |
|
| 572 | + switch($nodeNameSource) { |
|
| 573 | + case 'createdon': |
|
| 574 | + case 'editedon': |
|
| 575 | + case 'publishedon': |
|
| 576 | + case 'pub_date': |
|
| 577 | + case 'unpub_date': |
|
| 578 | + return true; |
|
| 579 | + default: |
|
| 580 | + return false; |
|
| 581 | + } |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -587,9 +587,9 @@ discard block |
||
| 587 | 587 | * @return int |
| 588 | 588 | */ |
| 589 | 589 | function checkIsFolder($parent = 0, $isfolder = 1) { |
| 590 | - global $modx; |
|
| 590 | + global $modx; |
|
| 591 | 591 | |
| 592 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 592 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -597,19 +597,19 @@ discard block |
||
| 597 | 597 | * @return string |
| 598 | 598 | */ |
| 599 | 599 | function _htmlentities($array) { |
| 600 | - global $modx; |
|
| 600 | + global $modx; |
|
| 601 | 601 | |
| 602 | - $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
| 603 | - $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
| 602 | + $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
| 603 | + $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
| 604 | 604 | |
| 605 | - return $array; |
|
| 605 | + return $array; |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
| 609 | 609 | * @return string |
| 610 | 610 | */ |
| 611 | 611 | function getTplSingleNode() { |
| 612 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 612 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 613 | 613 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 614 | 614 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 615 | 615 | data-id="[+id+]" |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * @return string |
| 637 | 637 | */ |
| 638 | 638 | function getTplFolderNode() { |
| 639 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 639 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 640 | 640 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 641 | 641 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 642 | 642 | data-id="[+id+]" |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * @return string |
| 676 | 676 | */ |
| 677 | 677 | function getTplFolderNodeNotChildren() { |
| 678 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 678 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
| 679 | 679 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 680 | 680 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
| 681 | 681 | data-id="[+id+]" |
@@ -711,10 +711,10 @@ discard block |
||
| 711 | 711 | * @param bool $flag |
| 712 | 712 | */ |
| 713 | 713 | function dbug($str, $flag = false) { |
| 714 | - print('<pre>'); |
|
| 715 | - print_r($str); |
|
| 716 | - print('</pre>'); |
|
| 717 | - if($flag) { |
|
| 718 | - exit; |
|
| 719 | - } |
|
| 714 | + print('<pre>'); |
|
| 715 | + print_r($str); |
|
| 716 | + print('</pre>'); |
|
| 717 | + if($flag) { |
|
| 718 | + exit; |
|
| 719 | + } |
|
| 720 | 720 | } |
@@ -11,7 +11,8 @@ discard block |
||
| 11 | 11 | * @param string $hereid |
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
| 14 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
| 15 | +{ |
|
| 15 | 16 | global $modx; |
| 16 | 17 | global $icons, $iconsPrivate, $_style; |
| 17 | 18 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -455,7 +456,8 @@ discard block |
||
| 455 | 456 | * @param array $_style |
| 456 | 457 | * @return array |
| 457 | 458 | */ |
| 458 | -function getIconInfo($_style) { |
|
| 459 | +function getIconInfo($_style) |
|
| 460 | +{ |
|
| 459 | 461 | if(!isset($_style['tree_page_gif'])) { |
| 460 | 462 | $_style['tree_page_gif'] = $_style['tree_page']; |
| 461 | 463 | } |
@@ -486,7 +488,8 @@ discard block |
||
| 486 | 488 | * @param array $_style |
| 487 | 489 | * @return array |
| 488 | 490 | */ |
| 489 | -function getPrivateIconInfo($_style) { |
|
| 491 | +function getPrivateIconInfo($_style) |
|
| 492 | +{ |
|
| 490 | 493 | if(!isset($_style['tree_page_gif_secure'])) { |
| 491 | 494 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
| 492 | 495 | } |
@@ -518,7 +521,8 @@ discard block |
||
| 518 | 521 | * @param array $row |
| 519 | 522 | * @return string |
| 520 | 523 | */ |
| 521 | -function getNodeTitle($nodeNameSource, $row) { |
|
| 524 | +function getNodeTitle($nodeNameSource, $row) |
|
| 525 | +{ |
|
| 522 | 526 | global $modx; |
| 523 | 527 | |
| 524 | 528 | switch($nodeNameSource) { |
@@ -568,7 +572,8 @@ discard block |
||
| 568 | 572 | * @param string $nodeNameSource |
| 569 | 573 | * @return bool |
| 570 | 574 | */ |
| 571 | -function isDateNode($nodeNameSource) { |
|
| 575 | +function isDateNode($nodeNameSource) |
|
| 576 | +{ |
|
| 572 | 577 | switch($nodeNameSource) { |
| 573 | 578 | case 'createdon': |
| 574 | 579 | case 'editedon': |
@@ -586,7 +591,8 @@ discard block |
||
| 586 | 591 | * @param int $isfolder |
| 587 | 592 | * @return int |
| 588 | 593 | */ |
| 589 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
| 594 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
| 595 | +{ |
|
| 590 | 596 | global $modx; |
| 591 | 597 | |
| 592 | 598 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
@@ -596,7 +602,8 @@ discard block |
||
| 596 | 602 | * @param mixed $array |
| 597 | 603 | * @return string |
| 598 | 604 | */ |
| 599 | -function _htmlentities($array) { |
|
| 605 | +function _htmlentities($array) |
|
| 606 | +{ |
|
| 600 | 607 | global $modx; |
| 601 | 608 | |
| 602 | 609 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -608,7 +615,8 @@ discard block |
||
| 608 | 615 | /** |
| 609 | 616 | * @return string |
| 610 | 617 | */ |
| 611 | -function getTplSingleNode() { |
|
| 618 | +function getTplSingleNode() |
|
| 619 | +{ |
|
| 612 | 620 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 613 | 621 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 614 | 622 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -635,7 +643,8 @@ discard block |
||
| 635 | 643 | /** |
| 636 | 644 | * @return string |
| 637 | 645 | */ |
| 638 | -function getTplFolderNode() { |
|
| 646 | +function getTplFolderNode() |
|
| 647 | +{ |
|
| 639 | 648 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 640 | 649 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 641 | 650 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -674,7 +683,8 @@ discard block |
||
| 674 | 683 | /** |
| 675 | 684 | * @return string |
| 676 | 685 | */ |
| 677 | -function getTplFolderNodeNotChildren() { |
|
| 686 | +function getTplFolderNodeNotChildren() |
|
| 687 | +{ |
|
| 678 | 688 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
| 679 | 689 | onclick="modx.tree.treeAction(event,[+id+]);" |
| 680 | 690 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -710,7 +720,8 @@ discard block |
||
| 710 | 720 | * @param int|string|array $str |
| 711 | 721 | * @param bool $flag |
| 712 | 722 | */ |
| 713 | -function dbug($str, $flag = false) { |
|
| 723 | +function dbug($str, $flag = false) |
|
| 724 | +{ |
|
| 714 | 725 | print('<pre>'); |
| 715 | 726 | print_r($str); |
| 716 | 727 | print('</pre>'); |
@@ -1,14 +1,14 @@ 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 | $tpl = array( |
| 7 | - 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
| 8 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
| 9 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
| 10 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
| 11 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
| 7 | + 'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'), |
|
| 8 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
| 9 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
| 10 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
| 11 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl') |
|
| 12 | 12 | ); |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | 19 | function parsePh($tpl, $ph) {
|
| 20 | - global $modx, $_lang; |
|
| 21 | - $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 22 | - return $modx->parseText($tpl, $ph); |
|
| 20 | + global $modx, $_lang; |
|
| 21 | + $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 22 | + return $modx->parseText($tpl, $ph); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function renderViewSwitchButtons($cssId) {
|
| 30 | - global $modx, $_lang, $tpl; |
|
| 30 | + global $modx, $_lang, $tpl; |
|
| 31 | 31 | |
| 32 | - return parsePh($tpl['viewForm'], array( |
|
| 33 | - 'cssId' => $cssId |
|
| 34 | - )); |
|
| 32 | + return parsePh($tpl['viewForm'], array( |
|
| 33 | + 'cssId' => $cssId |
|
| 34 | + )); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,52 +40,52 @@ discard block |
||
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | 42 | function createResourceList($resourceTable, $resources) {
|
| 43 | - global $modx, $_lang, $_style, $modx_textdir, $tpl; |
|
| 43 | + global $modx, $_lang, $_style, $modx_textdir, $tpl; |
|
| 44 | 44 | |
| 45 | - $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
|
| 45 | + $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
|
| 46 | 46 | |
| 47 | - if( ! is_array($items) || empty($items)) {
|
|
| 48 | - return $_lang['no_results']; |
|
| 49 | - } |
|
| 47 | + if( ! is_array($items) || empty($items)) {
|
|
| 48 | + return $_lang['no_results']; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - // Prepare elements- and categories-list |
|
| 52 | - $elements = array(); |
|
| 53 | - $categories = array(); |
|
| 54 | - foreach($items as $row) {
|
|
| 55 | - $catid = $row['catid'] ? $row['catid'] : 0; |
|
| 56 | - $categories[$catid] = array('name' => stripslashes($row['category']));
|
|
| 57 | - $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
|
| 58 | - } |
|
| 51 | + // Prepare elements- and categories-list |
|
| 52 | + $elements = array(); |
|
| 53 | + $categories = array(); |
|
| 54 | + foreach($items as $row) {
|
|
| 55 | + $catid = $row['catid'] ? $row['catid'] : 0; |
|
| 56 | + $categories[$catid] = array('name' => stripslashes($row['category']));
|
|
| 57 | + $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - // Now render categories / panel-collapse |
|
| 61 | - $panelGroup = ''; |
|
| 62 | - foreach($elements as $catid => $elList) {
|
|
| 63 | - // Add panel-heading / category-collapse to output |
|
| 64 | - $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
| 65 | - 'tab' => $resourceTable, |
|
| 66 | - 'category' => $categories[$catid]['name'], |
|
| 67 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 68 | - 'catid' => $catid, |
|
| 69 | - )); |
|
| 60 | + // Now render categories / panel-collapse |
|
| 61 | + $panelGroup = ''; |
|
| 62 | + foreach($elements as $catid => $elList) {
|
|
| 63 | + // Add panel-heading / category-collapse to output |
|
| 64 | + $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
| 65 | + 'tab' => $resourceTable, |
|
| 66 | + 'category' => $categories[$catid]['name'], |
|
| 67 | + 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 68 | + 'catid' => $catid, |
|
| 69 | + )); |
|
| 70 | 70 | |
| 71 | - // Prepare content for panel-collapse |
|
| 72 | - $panelCollapse = ''; |
|
| 73 | - foreach($elList as $el) {
|
|
| 74 | - $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
|
| 75 | - } |
|
| 71 | + // Prepare content for panel-collapse |
|
| 72 | + $panelCollapse = ''; |
|
| 73 | + foreach($elList as $el) {
|
|
| 74 | + $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - // Add panel-collapse with elements to output |
|
| 78 | - $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
| 79 | - 'tab' => $resourceTable, |
|
| 80 | - 'catid' => $catid, |
|
| 81 | - 'wrapper' => $panelCollapse, |
|
| 82 | - )); |
|
| 83 | - } |
|
| 77 | + // Add panel-collapse with elements to output |
|
| 78 | + $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
| 79 | + 'tab' => $resourceTable, |
|
| 80 | + 'catid' => $catid, |
|
| 81 | + 'wrapper' => $panelCollapse, |
|
| 82 | + )); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return parsePh($tpl['panelGroup'], array( |
|
| 86 | - 'resourceTable' => $resourceTable, |
|
| 87 | - 'wrapper' => $panelGroup |
|
| 88 | - )); |
|
| 85 | + return parsePh($tpl['panelGroup'], array( |
|
| 86 | + 'resourceTable' => $resourceTable, |
|
| 87 | + 'wrapper' => $panelGroup |
|
| 88 | + )); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -93,54 +93,54 @@ discard block |
||
| 93 | 93 | * @return string |
| 94 | 94 | */ |
| 95 | 95 | function createCombinedView($resources) {
|
| 96 | - global $modx, $_lang, $_style, $modx_textdir; |
|
| 96 | + global $modx, $_lang, $_style, $modx_textdir; |
|
| 97 | 97 | |
| 98 | - $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
|
| 99 | - $types = isset($resources->types) ? $resources->types : false; |
|
| 100 | - $categories = isset($resources->categories) ? $resources->categories : false; |
|
| 98 | + $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
|
| 99 | + $types = isset($resources->types) ? $resources->types : false; |
|
| 100 | + $categories = isset($resources->categories) ? $resources->categories : false; |
|
| 101 | 101 | |
| 102 | - if(!$itemsPerCategory) {
|
|
| 103 | - return $_lang['no_results']; |
|
| 104 | - } |
|
| 102 | + if(!$itemsPerCategory) {
|
|
| 103 | + return $_lang['no_results']; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $tpl = array( |
|
| 107 | - 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
| 108 | - 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
| 109 | - 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
| 110 | - 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
| 111 | - ); |
|
| 106 | + $tpl = array( |
|
| 107 | + 'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'), |
|
| 108 | + 'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'), |
|
| 109 | + 'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'), |
|
| 110 | + 'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'), |
|
| 111 | + ); |
|
| 112 | 112 | |
| 113 | - // Easily loop through $itemsPerCategory-Array |
|
| 114 | - $panelGroup = ''; |
|
| 115 | - foreach($categories as $catid => $category) {
|
|
| 116 | - // Prepare collapse content / elements-list |
|
| 117 | - $panelCollapse = ''; |
|
| 118 | - foreach($itemsPerCategory[$catid] as $el) {
|
|
| 119 | - $resourceTable = $el['type']; |
|
| 120 | - $ph = prepareElementRowPh($el, $resourceTable, $resources); |
|
| 121 | - $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
|
| 122 | - } |
|
| 113 | + // Easily loop through $itemsPerCategory-Array |
|
| 114 | + $panelGroup = ''; |
|
| 115 | + foreach($categories as $catid => $category) {
|
|
| 116 | + // Prepare collapse content / elements-list |
|
| 117 | + $panelCollapse = ''; |
|
| 118 | + foreach($itemsPerCategory[$catid] as $el) {
|
|
| 119 | + $resourceTable = $el['type']; |
|
| 120 | + $ph = prepareElementRowPh($el, $resourceTable, $resources); |
|
| 121 | + $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - // Add panel-heading / button |
|
| 125 | - $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
| 126 | - 'tab' => 'categories_list', |
|
| 127 | - 'category' => $categories[$catid], |
|
| 128 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 129 | - 'catid' => $catid, |
|
| 130 | - )); |
|
| 124 | + // Add panel-heading / button |
|
| 125 | + $panelGroup .= parsePh($tpl['panelHeading'], array( |
|
| 126 | + 'tab' => 'categories_list', |
|
| 127 | + 'category' => $categories[$catid], |
|
| 128 | + 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 129 | + 'catid' => $catid, |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | - // Add panel |
|
| 133 | - $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
| 134 | - 'tab' => 'categories_list', |
|
| 135 | - 'catid' => $catid, |
|
| 136 | - 'wrapper' => $panelCollapse, |
|
| 137 | - )); |
|
| 138 | - } |
|
| 132 | + // Add panel |
|
| 133 | + $panelGroup .= parsePh($tpl['panelCollapse'], array( |
|
| 134 | + 'tab' => 'categories_list', |
|
| 135 | + 'catid' => $catid, |
|
| 136 | + 'wrapper' => $panelCollapse, |
|
| 137 | + )); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - return parsePh($tpl['panelGroup'], array( |
|
| 141 | - 'resourceTable' => 'categories_list', |
|
| 142 | - 'wrapper' => $panelGroup |
|
| 143 | - )); |
|
| 140 | + return parsePh($tpl['panelGroup'], array( |
|
| 141 | + 'resourceTable' => 'categories_list', |
|
| 142 | + 'wrapper' => $panelGroup |
|
| 143 | + )); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | 152 | function prepareElementRowPh($row, $resourceTable, $resources) {
|
| 153 | - global $modx, $modx_textdir, $_style, $_lang; |
|
| 153 | + global $modx, $modx_textdir, $_style, $_lang; |
|
| 154 | 154 | |
| 155 | - $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
|
| 155 | + $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
|
| 156 | 156 | |
| 157 | - $_lang["confirm_delete"] = $_lang["delete"]; |
|
| 157 | + $_lang["confirm_delete"] = $_lang["delete"]; |
|
| 158 | 158 | |
| 159 | - switch($resourceTable){
|
|
| 159 | + switch($resourceTable){
|
|
| 160 | 160 | case 'site_templates': |
| 161 | 161 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
| 162 | 162 | $lockElementType = 1; |
@@ -190,77 +190,77 @@ discard block |
||
| 190 | 190 | return array(); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - // Prepare displaying user-locks |
|
| 194 | - $lockedByUser = ''; |
|
| 195 | - $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
|
| 196 | - if($rowLock && $modx->hasPermission('display_locks')) {
|
|
| 197 | - if($rowLock['sid'] == $modx->sid) {
|
|
| 198 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 199 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 200 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 201 | - )); |
|
| 202 | - $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
| 203 | - } else {
|
|
| 204 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 205 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 206 | - 'username' => $rowLock['username'], |
|
| 207 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 208 | - )); |
|
| 209 | - if($modx->hasPermission('remove_locks')) {
|
|
| 210 | - $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
|
|
| 211 | - } else {
|
|
| 212 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - if($lockedByUser) {
|
|
| 217 | - $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
| 218 | - } |
|
| 193 | + // Prepare displaying user-locks |
|
| 194 | + $lockedByUser = ''; |
|
| 195 | + $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
|
| 196 | + if($rowLock && $modx->hasPermission('display_locks')) {
|
|
| 197 | + if($rowLock['sid'] == $modx->sid) {
|
|
| 198 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
| 199 | + 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 200 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 201 | + )); |
|
| 202 | + $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
| 203 | + } else {
|
|
| 204 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
| 205 | + 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 206 | + 'username' => $rowLock['username'], |
|
| 207 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
| 208 | + )); |
|
| 209 | + if($modx->hasPermission('remove_locks')) {
|
|
| 210 | + $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
|
|
| 211 | + } else {
|
|
| 212 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + if($lockedByUser) {
|
|
| 217 | + $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - // Caption |
|
| 221 | - if($resourceTable == 'site_tmplvars') {
|
|
| 222 | - $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
|
|
| 223 | - } else {
|
|
| 224 | - $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
| 225 | - } |
|
| 220 | + // Caption |
|
| 221 | + if($resourceTable == 'site_tmplvars') {
|
|
| 222 | + $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
|
|
| 223 | + } else {
|
|
| 224 | + $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - // Special marks |
|
| 228 | - $tplInfo = array(); |
|
| 229 | - if($row['locked']) {
|
|
| 230 | - $tplInfo[] = $_lang['locked']; |
|
| 231 | - } |
|
| 232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
|
|
| 233 | - $tplInfo[] = $_lang['defaulttemplate_title']; |
|
| 234 | - } |
|
| 235 | - $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
|
|
| 227 | + // Special marks |
|
| 228 | + $tplInfo = array(); |
|
| 229 | + if($row['locked']) {
|
|
| 230 | + $tplInfo[] = $_lang['locked']; |
|
| 231 | + } |
|
| 232 | + if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
|
|
| 233 | + $tplInfo[] = $_lang['defaulttemplate_title']; |
|
| 234 | + } |
|
| 235 | + $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
|
|
| 236 | 236 | |
| 237 | - /* row buttons */ |
|
| 238 | - $buttons = ''; |
|
| 239 | - if($modx->hasPermission($types['actions']['edit'][1])) {
|
|
| 240 | - $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
| 241 | - } |
|
| 242 | - if($modx->hasPermission($types['actions']['duplicate'][1])) {
|
|
| 243 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
| 244 | - } |
|
| 245 | - if($modx->hasPermission($types['actions']['remove'][1])) {
|
|
| 246 | - $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
| 247 | - } |
|
| 248 | - $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
| 237 | + /* row buttons */ |
|
| 238 | + $buttons = ''; |
|
| 239 | + if($modx->hasPermission($types['actions']['edit'][1])) {
|
|
| 240 | + $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
|
| 241 | + } |
|
| 242 | + if($modx->hasPermission($types['actions']['duplicate'][1])) {
|
|
| 243 | + $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
|
| 244 | + } |
|
| 245 | + if($modx->hasPermission($types['actions']['remove'][1])) {
|
|
| 246 | + $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
|
| 247 | + } |
|
| 248 | + $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
| 249 | 249 | |
| 250 | - $catid = $row['catid'] ? $row['catid'] : 0; |
|
| 250 | + $catid = $row['catid'] ? $row['catid'] : 0; |
|
| 251 | 251 | |
| 252 | - // Placeholders for elements-row |
|
| 253 | - return array( |
|
| 254 | - 'class' => $class ? ' class="' . $class . '"' : '', |
|
| 255 | - 'lockedByUser' => $lockedByUser, |
|
| 256 | - 'name' => $row['name'], |
|
| 257 | - 'caption' => $caption, |
|
| 258 | - 'buttons' => $buttons, |
|
| 259 | - 'marks' => $marks, |
|
| 260 | - 'id' => $row['id'], |
|
| 261 | - 'resourceTable' => $resourceTable, |
|
| 262 | - 'actionEdit' => $types['actions']['edit'][0], |
|
| 263 | - 'catid' => $catid, |
|
| 264 | - 'textdir' => $modx_textdir ? '‏' : '', |
|
| 265 | - ); |
|
| 252 | + // Placeholders for elements-row |
|
| 253 | + return array( |
|
| 254 | + 'class' => $class ? ' class="' . $class . '"' : '', |
|
| 255 | + 'lockedByUser' => $lockedByUser, |
|
| 256 | + 'name' => $row['name'], |
|
| 257 | + 'caption' => $caption, |
|
| 258 | + 'buttons' => $buttons, |
|
| 259 | + 'marks' => $marks, |
|
| 260 | + 'id' => $row['id'], |
|
| 261 | + 'resourceTable' => $resourceTable, |
|
| 262 | + 'actionEdit' => $types['actions']['edit'][0], |
|
| 263 | + 'catid' => $catid, |
|
| 264 | + 'textdir' => $modx_textdir ? '‏' : '', |
|
| 265 | + ); |
|
| 266 | 266 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | 5 | |
@@ -16,7 +16,8 @@ discard block |
||
| 16 | 16 | * @param array $ph |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | -function parsePh($tpl, $ph) {
|
|
| 19 | +function parsePh($tpl, $ph) |
|
| 20 | +{ |
|
| 20 | 21 | global $modx, $_lang; |
| 21 | 22 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
| 22 | 23 | return $modx->parseText($tpl, $ph); |
@@ -26,7 +27,8 @@ discard block |
||
| 26 | 27 | * @param string|int $cssId |
| 27 | 28 | * @return string |
| 28 | 29 | */ |
| 29 | -function renderViewSwitchButtons($cssId) {
|
|
| 30 | +function renderViewSwitchButtons($cssId) |
|
| 31 | +{ |
|
| 30 | 32 | global $modx, $_lang, $tpl; |
| 31 | 33 | |
| 32 | 34 | return parsePh($tpl['viewForm'], array( |
@@ -39,19 +41,20 @@ discard block |
||
| 39 | 41 | * @param mgrResources $resources |
| 40 | 42 | * @return string |
| 41 | 43 | */ |
| 42 | -function createResourceList($resourceTable, $resources) {
|
|
| 44 | +function createResourceList($resourceTable, $resources) |
|
| 45 | +{ |
|
| 43 | 46 | global $modx, $_lang, $_style, $modx_textdir, $tpl; |
| 44 | 47 | |
| 45 | 48 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
| 46 | 49 | |
| 47 | - if( ! is_array($items) || empty($items)) {
|
|
| 50 | + if( ! is_array($items) || empty($items)) { |
|
| 48 | 51 | return $_lang['no_results']; |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | // Prepare elements- and categories-list |
| 52 | 55 | $elements = array(); |
| 53 | 56 | $categories = array(); |
| 54 | - foreach($items as $row) {
|
|
| 57 | + foreach($items as $row) { |
|
| 55 | 58 | $catid = $row['catid'] ? $row['catid'] : 0; |
| 56 | 59 | $categories[$catid] = array('name' => stripslashes($row['category']));
|
| 57 | 60 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
@@ -59,7 +62,7 @@ discard block |
||
| 59 | 62 | |
| 60 | 63 | // Now render categories / panel-collapse |
| 61 | 64 | $panelGroup = ''; |
| 62 | - foreach($elements as $catid => $elList) {
|
|
| 65 | + foreach($elements as $catid => $elList) { |
|
| 63 | 66 | // Add panel-heading / category-collapse to output |
| 64 | 67 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
| 65 | 68 | 'tab' => $resourceTable, |
@@ -70,7 +73,7 @@ discard block |
||
| 70 | 73 | |
| 71 | 74 | // Prepare content for panel-collapse |
| 72 | 75 | $panelCollapse = ''; |
| 73 | - foreach($elList as $el) {
|
|
| 76 | + foreach($elList as $el) { |
|
| 74 | 77 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
| 75 | 78 | } |
| 76 | 79 | |
@@ -92,14 +95,15 @@ discard block |
||
| 92 | 95 | * @param mgrResources $resources |
| 93 | 96 | * @return string |
| 94 | 97 | */ |
| 95 | -function createCombinedView($resources) {
|
|
| 98 | +function createCombinedView($resources) |
|
| 99 | +{ |
|
| 96 | 100 | global $modx, $_lang, $_style, $modx_textdir; |
| 97 | 101 | |
| 98 | 102 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
| 99 | 103 | $types = isset($resources->types) ? $resources->types : false; |
| 100 | 104 | $categories = isset($resources->categories) ? $resources->categories : false; |
| 101 | 105 | |
| 102 | - if(!$itemsPerCategory) {
|
|
| 106 | + if(!$itemsPerCategory) { |
|
| 103 | 107 | return $_lang['no_results']; |
| 104 | 108 | } |
| 105 | 109 | |
@@ -112,10 +116,10 @@ discard block |
||
| 112 | 116 | |
| 113 | 117 | // Easily loop through $itemsPerCategory-Array |
| 114 | 118 | $panelGroup = ''; |
| 115 | - foreach($categories as $catid => $category) {
|
|
| 119 | + foreach($categories as $catid => $category) { |
|
| 116 | 120 | // Prepare collapse content / elements-list |
| 117 | 121 | $panelCollapse = ''; |
| 118 | - foreach($itemsPerCategory[$catid] as $el) {
|
|
| 122 | + foreach($itemsPerCategory[$catid] as $el) { |
|
| 119 | 123 | $resourceTable = $el['type']; |
| 120 | 124 | $ph = prepareElementRowPh($el, $resourceTable, $resources); |
| 121 | 125 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
@@ -149,14 +153,15 @@ discard block |
||
| 149 | 153 | * @param mgrResources $resources |
| 150 | 154 | * @return array |
| 151 | 155 | */ |
| 152 | -function prepareElementRowPh($row, $resourceTable, $resources) {
|
|
| 156 | +function prepareElementRowPh($row, $resourceTable, $resources) |
|
| 157 | +{ |
|
| 153 | 158 | global $modx, $modx_textdir, $_style, $_lang; |
| 154 | 159 | |
| 155 | 160 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
| 156 | 161 | |
| 157 | 162 | $_lang["confirm_delete"] = $_lang["delete"]; |
| 158 | 163 | |
| 159 | - switch($resourceTable){
|
|
| 164 | + switch($resourceTable) { |
|
| 160 | 165 | case 'site_templates': |
| 161 | 166 | $class = $row['selectable'] ? '' : 'disabledPlugin'; |
| 162 | 167 | $lockElementType = 1; |
@@ -193,56 +198,56 @@ discard block |
||
| 193 | 198 | // Prepare displaying user-locks |
| 194 | 199 | $lockedByUser = ''; |
| 195 | 200 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
| 196 | - if($rowLock && $modx->hasPermission('display_locks')) {
|
|
| 197 | - if($rowLock['sid'] == $modx->sid) {
|
|
| 201 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
| 202 | + if($rowLock['sid'] == $modx->sid) { |
|
| 198 | 203 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
| 199 | 204 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
| 200 | 205 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 201 | 206 | )); |
| 202 | 207 | $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
| 203 | - } else {
|
|
| 208 | + } else { |
|
| 204 | 209 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
| 205 | 210 | 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
| 206 | 211 | 'username' => $rowLock['username'], |
| 207 | 212 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 208 | 213 | )); |
| 209 | - if($modx->hasPermission('remove_locks')) {
|
|
| 214 | + if($modx->hasPermission('remove_locks')) { |
|
| 210 | 215 | $lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
|
| 211 | - } else {
|
|
| 216 | + } else { |
|
| 212 | 217 | $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
| 213 | 218 | } |
| 214 | 219 | } |
| 215 | 220 | } |
| 216 | - if($lockedByUser) {
|
|
| 221 | + if($lockedByUser) { |
|
| 217 | 222 | $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
| 218 | 223 | } |
| 219 | 224 | |
| 220 | 225 | // Caption |
| 221 | - if($resourceTable == 'site_tmplvars') {
|
|
| 226 | + if($resourceTable == 'site_tmplvars') { |
|
| 222 | 227 | $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
|
| 223 | - } else {
|
|
| 228 | + } else { |
|
| 224 | 229 | $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
| 225 | 230 | } |
| 226 | 231 | |
| 227 | 232 | // Special marks |
| 228 | 233 | $tplInfo = array(); |
| 229 | - if($row['locked']) {
|
|
| 234 | + if($row['locked']) { |
|
| 230 | 235 | $tplInfo[] = $_lang['locked']; |
| 231 | 236 | } |
| 232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
|
|
| 237 | + if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') { |
|
| 233 | 238 | $tplInfo[] = $_lang['defaulttemplate_title']; |
| 234 | 239 | } |
| 235 | 240 | $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
|
| 236 | 241 | |
| 237 | 242 | /* row buttons */ |
| 238 | 243 | $buttons = ''; |
| 239 | - if($modx->hasPermission($types['actions']['edit'][1])) {
|
|
| 244 | + if($modx->hasPermission($types['actions']['edit'][1])) { |
|
| 240 | 245 | $buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>'; |
| 241 | 246 | } |
| 242 | - if($modx->hasPermission($types['actions']['duplicate'][1])) {
|
|
| 247 | + if($modx->hasPermission($types['actions']['duplicate'][1])) { |
|
| 243 | 248 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>'; |
| 244 | 249 | } |
| 245 | - if($modx->hasPermission($types['actions']['remove'][1])) {
|
|
| 250 | + if($modx->hasPermission($types['actions']['remove'][1])) { |
|
| 246 | 251 | $buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>'; |
| 247 | 252 | } |
| 248 | 253 | $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * @var array |
| 9 | 9 | */ |
| 10 | - public $types = array(); |
|
| 10 | + public $types = array(); |
|
| 11 | 11 | /** |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
@@ -25,73 +25,73 @@ discard block |
||
| 25 | 25 | * mgrResources constructor. |
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | - $this->setTypes(); |
|
| 29 | - $this->queryItemsFromDB(); |
|
| 30 | - $this->prepareCategoryArrays(); |
|
| 31 | - } |
|
| 28 | + $this->setTypes(); |
|
| 29 | + $this->queryItemsFromDB(); |
|
| 30 | + $this->prepareCategoryArrays(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | 36 | public function setTypes() { |
| 37 | - global $_lang; |
|
| 38 | - $this->types['site_templates'] = array( |
|
| 39 | - 'title'=>$_lang["manage_templates"], |
|
| 40 | - 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
| 41 | - 'permissions'=>array('new_template','edit_template'), |
|
| 42 | - 'name'=>'templatename' |
|
| 43 | - ); |
|
| 44 | - $this->types['site_tmplvars'] = array( |
|
| 45 | - 'title'=>$_lang["tmplvars"], |
|
| 46 | - 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
| 47 | - 'permissions'=>array('new_template','edit_template'), |
|
| 48 | - ); |
|
| 49 | - $this->types['site_htmlsnippets'] = array( |
|
| 50 | - 'title'=>$_lang["manage_htmlsnippets"], |
|
| 51 | - 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
| 52 | - 'permissions'=>array('new_chunk','edit_chunk'), |
|
| 53 | - ); |
|
| 54 | - $this->types['site_snippets'] = array( |
|
| 55 | - 'title'=>$_lang["manage_snippets"], |
|
| 56 | - 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
| 57 | - 'permissions'=>array('new_snippet','edit_snippet'), |
|
| 58 | - ); |
|
| 59 | - $this->types['site_plugins'] = array( |
|
| 60 | - 'title'=>$_lang["manage_plugins"], |
|
| 61 | - 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
| 62 | - 'permissions'=>array('new_plugin','edit_plugin'), |
|
| 63 | - ); |
|
| 64 | - $this->types['site_modules'] = array( |
|
| 65 | - 'title'=>$_lang["manage_modules"], |
|
| 66 | - 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
| 67 | - 'permissions'=>array('new_module','edit_module'), |
|
| 68 | - ); |
|
| 69 | - } |
|
| 37 | + global $_lang; |
|
| 38 | + $this->types['site_templates'] = array( |
|
| 39 | + 'title'=>$_lang["manage_templates"], |
|
| 40 | + 'actions'=>array( 'edit'=>array(16,'edit_template'), 'duplicate'=>array(96,'new_template'), 'remove'=>array(21,'delete_template') ), |
|
| 41 | + 'permissions'=>array('new_template','edit_template'), |
|
| 42 | + 'name'=>'templatename' |
|
| 43 | + ); |
|
| 44 | + $this->types['site_tmplvars'] = array( |
|
| 45 | + 'title'=>$_lang["tmplvars"], |
|
| 46 | + 'actions'=>array('edit'=>array(301,'edit_template'), 'duplicate'=>array(304,'edit_template'), 'remove'=>array(303,'edit_template')), |
|
| 47 | + 'permissions'=>array('new_template','edit_template'), |
|
| 48 | + ); |
|
| 49 | + $this->types['site_htmlsnippets'] = array( |
|
| 50 | + 'title'=>$_lang["manage_htmlsnippets"], |
|
| 51 | + 'actions'=>array('edit'=>array(78,'edit_chunk'), 'duplicate'=>array(97,'new_chunk'), 'remove'=>array(80,'delete_chunk')), |
|
| 52 | + 'permissions'=>array('new_chunk','edit_chunk'), |
|
| 53 | + ); |
|
| 54 | + $this->types['site_snippets'] = array( |
|
| 55 | + 'title'=>$_lang["manage_snippets"], |
|
| 56 | + 'actions'=>array('edit'=>array(22,'edit_snippet'), 'duplicate'=>array(98,'new_snippet'), 'remove'=>array(25,'delete_snippet')), |
|
| 57 | + 'permissions'=>array('new_snippet','edit_snippet'), |
|
| 58 | + ); |
|
| 59 | + $this->types['site_plugins'] = array( |
|
| 60 | + 'title'=>$_lang["manage_plugins"], |
|
| 61 | + 'actions'=>array('edit'=>array(102,'edit_plugin'), 'duplicate'=>array(105,'new_plugin'), 'remove'=>array(104,'delete_plugin')), |
|
| 62 | + 'permissions'=>array('new_plugin','edit_plugin'), |
|
| 63 | + ); |
|
| 64 | + $this->types['site_modules'] = array( |
|
| 65 | + 'title'=>$_lang["manage_modules"], |
|
| 66 | + 'actions'=>array('edit'=>array(108,'edit_module'), 'duplicate'=>array(111,'new_module'), 'remove'=>array(110,'delete_module')), |
|
| 67 | + 'permissions'=>array('new_module','edit_module'), |
|
| 68 | + ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | 74 | public function queryItemsFromDB() { |
| 75 | - foreach($this->types as $resourceTable=>$type) { |
|
| 76 | - if($this->hasAnyPermissions($type['permissions'])) { |
|
| 77 | - $nameField = isset($type['name']) ? $type['name'] : 'name'; |
|
| 78 | - $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - } |
|
| 75 | + foreach($this->types as $resourceTable=>$type) { |
|
| 76 | + if($this->hasAnyPermissions($type['permissions'])) { |
|
| 77 | + $nameField = isset($type['name']) ? $type['name'] : 'name'; |
|
| 78 | + $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @param array $permissions |
| 85 | 85 | * @return bool |
| 86 | 86 | */ |
| 87 | 87 | public function hasAnyPermissions($permissions) { |
| 88 | - global $modx; |
|
| 88 | + global $modx; |
|
| 89 | 89 | |
| 90 | - foreach($permissions as $p) |
|
| 91 | - if($modx->hasPermission($p)) return true; |
|
| 90 | + foreach($permissions as $p) |
|
| 91 | + if($modx->hasPermission($p)) return true; |
|
| 92 | 92 | |
| 93 | - return false; |
|
| 94 | - } |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * @param string $resourceTable |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @return array|bool |
| 100 | 100 | */ |
| 101 | 101 | public function queryResources($resourceTable, $nameField = 'name') { |
| 102 | - global $modx, $_lang; |
|
| 102 | + global $modx, $_lang; |
|
| 103 | 103 | |
| 104 | 104 | $allowed = array( |
| 105 | 105 | 'site_htmlsnippets', |
@@ -107,59 +107,59 @@ discard block |
||
| 107 | 107 | 'site_plugins', |
| 108 | 108 | 'site_modules' |
| 109 | 109 | ); |
| 110 | - $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
| 111 | - |
|
| 112 | - $tvsql = ''; |
|
| 113 | - $tvjoin = ''; |
|
| 114 | - if ($resourceTable === 'site_tmplvars') { |
|
| 115 | - $tvsql = 'site_tmplvars.caption, '; |
|
| 116 | - $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
|
| 117 | - $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
|
| 118 | - } |
|
| 119 | - else $sttfield = ''; |
|
| 120 | - |
|
| 121 | - $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
|
| 122 | - |
|
| 123 | - $rs = $modx->db->select( |
|
| 124 | - "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
|
| 125 | - $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
| 110 | + $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
| 111 | + |
|
| 112 | + $tvsql = ''; |
|
| 113 | + $tvjoin = ''; |
|
| 114 | + if ($resourceTable === 'site_tmplvars') { |
|
| 115 | + $tvsql = 'site_tmplvars.caption, '; |
|
| 116 | + $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
|
| 117 | + $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
|
| 118 | + } |
|
| 119 | + else $sttfield = ''; |
|
| 120 | + |
|
| 121 | + $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
|
| 122 | + |
|
| 123 | + $rs = $modx->db->select( |
|
| 124 | + "{$sttfield} {$pluginsql} {$tvsql} {$resourceTable}.{$nameField} as name, {$resourceTable}.id, {$resourceTable}.description, {$resourceTable}.locked, {$selectableTemplates}IF(isnull(categories.category),'{$_lang['no_category']}',categories.category) as category, categories.id as catid", |
|
| 125 | + $modx->getFullTableName($resourceTable) . " AS {$resourceTable} |
|
| 126 | 126 | LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
| 127 | - "", |
|
| 128 | - "category,name" |
|
| 129 | - ); |
|
| 130 | - $limit = $modx->db->getRecordCount($rs); |
|
| 127 | + "", |
|
| 128 | + "category,name" |
|
| 129 | + ); |
|
| 130 | + $limit = $modx->db->getRecordCount($rs); |
|
| 131 | 131 | |
| 132 | - if($limit < 1) return false; |
|
| 132 | + if($limit < 1) return false; |
|
| 133 | 133 | |
| 134 | - $result = array(); |
|
| 135 | - while ($row = $modx->db->getRow($rs)) { |
|
| 136 | - $result[] = $row; |
|
| 137 | - } |
|
| 138 | - return $result; |
|
| 139 | - } |
|
| 134 | + $result = array(); |
|
| 135 | + while ($row = $modx->db->getRow($rs)) { |
|
| 136 | + $result[] = $row; |
|
| 137 | + } |
|
| 138 | + return $result; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * @return void |
| 143 | 143 | */ |
| 144 | 144 | public function prepareCategoryArrays() { |
| 145 | - foreach($this->items as $type=>$items) { |
|
| 146 | - foreach((array)$items as $item) { |
|
| 147 | - $catid = $item['catid'] ? $item['catid'] : 0; |
|
| 148 | - $this->categories[$catid] = $item['category']; |
|
| 149 | - |
|
| 150 | - $item['type'] = $type; |
|
| 151 | - $this->itemsPerCategory[$catid][] = $item; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // Sort categories by name |
|
| 156 | - natcasesort($this->categories); |
|
| 157 | - |
|
| 158 | - // Now sort by name |
|
| 159 | - foreach($this->itemsPerCategory as $catid=>$items) { |
|
| 160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 161 | - return strcasecmp($a['name'], $b['name']); |
|
| 162 | - }); |
|
| 163 | - } |
|
| 164 | - } |
|
| 145 | + foreach($this->items as $type=>$items) { |
|
| 146 | + foreach((array)$items as $item) { |
|
| 147 | + $catid = $item['catid'] ? $item['catid'] : 0; |
|
| 148 | + $this->categories[$catid] = $item['category']; |
|
| 149 | + |
|
| 150 | + $item['type'] = $type; |
|
| 151 | + $this->itemsPerCategory[$catid][] = $item; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // Sort categories by name |
|
| 156 | + natcasesort($this->categories); |
|
| 157 | + |
|
| 158 | + // Now sort by name |
|
| 159 | + foreach($this->itemsPerCategory as $catid=>$items) { |
|
| 160 | + usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 161 | + return strcasecmp($a['name'], $b['name']); |
|
| 162 | + }); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | } |
@@ -3,7 +3,8 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -class mgrResources { |
|
| 6 | +class mgrResources |
|
| 7 | +{ |
|
| 7 | 8 | /** |
| 8 | 9 | * @var array |
| 9 | 10 | */ |
@@ -24,7 +25,8 @@ discard block |
||
| 24 | 25 | /** |
| 25 | 26 | * mgrResources constructor. |
| 26 | 27 | */ |
| 27 | - public function __construct() { |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 28 | 30 | $this->setTypes(); |
| 29 | 31 | $this->queryItemsFromDB(); |
| 30 | 32 | $this->prepareCategoryArrays(); |
@@ -33,7 +35,8 @@ discard block |
||
| 33 | 35 | /** |
| 34 | 36 | * @return void |
| 35 | 37 | */ |
| 36 | - public function setTypes() { |
|
| 38 | + public function setTypes() |
|
| 39 | + { |
|
| 37 | 40 | global $_lang; |
| 38 | 41 | $this->types['site_templates'] = array( |
| 39 | 42 | 'title'=>$_lang["manage_templates"], |
@@ -71,7 +74,8 @@ discard block |
||
| 71 | 74 | /** |
| 72 | 75 | * @return void |
| 73 | 76 | */ |
| 74 | - public function queryItemsFromDB() { |
|
| 77 | + public function queryItemsFromDB() |
|
| 78 | + { |
|
| 75 | 79 | foreach($this->types as $resourceTable=>$type) { |
| 76 | 80 | if($this->hasAnyPermissions($type['permissions'])) { |
| 77 | 81 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
@@ -84,11 +88,13 @@ discard block |
||
| 84 | 88 | * @param array $permissions |
| 85 | 89 | * @return bool |
| 86 | 90 | */ |
| 87 | - public function hasAnyPermissions($permissions) { |
|
| 91 | + public function hasAnyPermissions($permissions) |
|
| 92 | + { |
|
| 88 | 93 | global $modx; |
| 89 | 94 | |
| 90 | - foreach($permissions as $p) |
|
| 91 | - if($modx->hasPermission($p)) return true; |
|
| 95 | + foreach($permissions as $p) { |
|
| 96 | + if($modx->hasPermission($p)) return true; |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | 99 | return false; |
| 94 | 100 | } |
@@ -98,7 +104,8 @@ discard block |
||
| 98 | 104 | * @param string $nameField |
| 99 | 105 | * @return array|bool |
| 100 | 106 | */ |
| 101 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
| 107 | + public function queryResources($resourceTable, $nameField = 'name') |
|
| 108 | + { |
|
| 102 | 109 | global $modx, $_lang; |
| 103 | 110 | |
| 104 | 111 | $allowed = array( |
@@ -115,8 +122,9 @@ discard block |
||
| 115 | 122 | $tvsql = 'site_tmplvars.caption, '; |
| 116 | 123 | $tvjoin = sprintf('LEFT JOIN %s AS stt ON site_tmplvars.id=stt.tmplvarid GROUP BY site_tmplvars.id,reltpl', $modx->getFullTableName('site_tmplvar_templates')); |
| 117 | 124 | $sttfield = 'IF(stt.templateid,1,0) AS reltpl,'; |
| 125 | + } else { |
|
| 126 | + $sttfield = ''; |
|
| 118 | 127 | } |
| 119 | - else $sttfield = ''; |
|
| 120 | 128 | |
| 121 | 129 | $selectableTemplates = $resourceTable === 'site_templates' ? "{$resourceTable}.selectable, " : ""; |
| 122 | 130 | |
@@ -129,7 +137,9 @@ discard block |
||
| 129 | 137 | ); |
| 130 | 138 | $limit = $modx->db->getRecordCount($rs); |
| 131 | 139 | |
| 132 | - if($limit < 1) return false; |
|
| 140 | + if($limit < 1) { |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 133 | 143 | |
| 134 | 144 | $result = array(); |
| 135 | 145 | while ($row = $modx->db->getRow($rs)) { |
@@ -141,7 +151,8 @@ discard block |
||
| 141 | 151 | /** |
| 142 | 152 | * @return void |
| 143 | 153 | */ |
| 144 | - public function prepareCategoryArrays() { |
|
| 154 | + public function prepareCategoryArrays() |
|
| 155 | + { |
|
| 145 | 156 | foreach($this->items as $type=>$items) { |
| 146 | 157 | foreach((array)$items as $item) { |
| 147 | 158 | $catid = $item['catid'] ? $item['catid'] : 0; |
@@ -157,7 +168,7 @@ discard block |
||
| 157 | 168 | |
| 158 | 169 | // Now sort by name |
| 159 | 170 | foreach($this->itemsPerCategory as $catid=>$items) { |
| 160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 171 | + usort($this->itemsPerCategory[$catid], function ($a, $b){ |
|
| 161 | 172 | return strcasecmp($a['name'], $b['name']); |
| 162 | 173 | }); |
| 163 | 174 | } |
@@ -893,7 +893,9 @@ |
||
| 893 | 893 | global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
| 894 | 894 | $msg = ''; |
| 895 | 895 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 896 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
| 896 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
| 897 | + continue; |
|
| 898 | + } |
|
| 897 | 899 | $userfile= array(); |
| 898 | 900 | |
| 899 | 901 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | * @param string $filename |
| 6 | 6 | * @return array of keys from a language file |
| 7 | 7 | */ |
| 8 | -function get_lang_keys($filename) |
|
| 9 | -{
|
|
| 8 | +function get_lang_keys($filename) |
|
| 9 | +{ |
|
| 10 | 10 | $file = MODX_MANAGER_PATH . 'includes/lang' . DIRECTORY_SEPARATOR . $filename; |
| 11 | - if (is_file($file) && is_readable($file)) {
|
|
| 11 | + if (is_file($file) && is_readable($file)) { |
|
| 12 | 12 | include($file); |
| 13 | 13 | $out = isset($_lang) ? array_keys($_lang) : array(); |
| 14 | - } else {
|
|
| 14 | + } else { |
|
| 15 | 15 | $out = array(); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | * @param string $key |
| 25 | 25 | * @return array of languages that define the key in their file |
| 26 | 26 | */ |
| 27 | -function get_langs_by_key($key) |
|
| 28 | -{
|
|
| 27 | +function get_langs_by_key($key) |
|
| 28 | +{ |
|
| 29 | 29 | global $lang_keys; |
| 30 | 30 | $lang_return = array(); |
| 31 | - foreach ($lang_keys as $lang => $keys) {
|
|
| 32 | - if (in_array($key, $keys)) {
|
|
| 31 | + foreach ($lang_keys as $lang => $keys) { |
|
| 32 | + if (in_array($key, $keys)) { |
|
| 33 | 33 | $lang_return[] = $lang; |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -46,25 +46,25 @@ discard block |
||
| 46 | 46 | * @param string $selected_lang specify language to select in option list, default none |
| 47 | 47 | * @return string html option list |
| 48 | 48 | */ |
| 49 | -function get_lang_options($key = '', $selected_lang = '') |
|
| 50 | -{
|
|
| 49 | +function get_lang_options($key = '', $selected_lang = '') |
|
| 50 | +{ |
|
| 51 | 51 | global $lang_keys, $_lang; |
| 52 | 52 | $lang_options = ''; |
| 53 | - if (!empty($key)) {
|
|
| 53 | + if (!empty($key)) { |
|
| 54 | 54 | $languages = get_langs_by_key($key); |
| 55 | 55 | sort($languages); |
| 56 | 56 | $lang_options .= '<option value="">' . $_lang['language_title'] . '</option>'; |
| 57 | 57 | |
| 58 | - foreach ($languages as $language_name) {
|
|
| 58 | + foreach ($languages as $language_name) { |
|
| 59 | 59 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 60 | 60 | $lang_options .= '<option value="' . $language_name . '">' . $uclanguage_name . '</option>'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | return $lang_options; |
| 64 | - } else {
|
|
| 64 | + } else { |
|
| 65 | 65 | $languages = array_keys($lang_keys); |
| 66 | 66 | sort($languages); |
| 67 | - foreach ($languages as $language_name) {
|
|
| 67 | + foreach ($languages as $language_name) { |
|
| 68 | 68 | $uclanguage_name = ucwords(str_replace("_", " ", $language_name));
|
| 69 | 69 | $sel = $language_name === $selected_lang ? ' selected="selected"' : ''; |
| 70 | 70 | $lang_options .= '<option value="' . $language_name . '" ' . $sel . '>' . $uclanguage_name . '</option>'; |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | * @param bool $disabled |
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | -function form_radio($name, $value, $add = '', $disabled = false) |
|
| 85 | -{
|
|
| 84 | +function form_radio($name, $value, $add = '', $disabled = false) |
|
| 85 | +{ |
|
| 86 | 86 | global ${$name};
|
| 87 | 87 | $var = ${$name};
|
| 88 | 88 | $checked = ($var == $value) ? ' checked="checked"' : ''; |
| 89 | - if ($disabled) {
|
|
| 89 | + if ($disabled) { |
|
| 90 | 90 | $disabled = ' disabled'; |
| 91 | - } else {
|
|
| 91 | + } else { |
|
| 92 | 92 | $disabled = ''; |
| 93 | 93 | } |
| 94 | - if ($add) {
|
|
| 94 | + if ($add) { |
|
| 95 | 95 | $add = ' ' . $add; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $object |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | -function wrap_label($str = '', $object) |
|
| 108 | -{
|
|
| 107 | +function wrap_label($str = '', $object) |
|
| 108 | +{ |
|
| 109 | 109 | return "<label>{$object}\n{$str}</label>";
|
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | * @param array $ph |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | -function parseText($tpl = '', $ph = array()) |
|
| 118 | -{
|
|
| 119 | - if (empty($ph) || empty($tpl)) {
|
|
| 117 | +function parseText($tpl = '', $ph = array()) |
|
| 118 | +{ |
|
| 119 | + if (empty($ph) || empty($tpl)) { |
|
| 120 | 120 | return $tpl; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - foreach ($ph as $k => $v) {
|
|
| 123 | + foreach ($ph as $k => $v) { |
|
| 124 | 124 | $k = "[+{$k}+]";
|
| 125 | 125 | $tpl = str_replace($k, $v, $tpl); |
| 126 | 126 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * @param bool $cond |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | -function showHide($cond = true) |
|
| 136 | -{
|
|
| 135 | +function showHide($cond = true) |
|
| 136 | +{ |
|
| 137 | 137 | global $displayStyle; |
| 138 | 138 | $showHide = $cond ? $displayStyle : 'none'; |
| 139 | 139 | |
@@ -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']) ? (int)$_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 = (int)$_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 = (int)$_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,63 +1517,63 @@ 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 | /** |
| 1536 | 1536 | * @return string |
| 1537 | 1537 | */ |
| 1538 | 1538 | function getDefaultTemplate() { |
| 1539 | - global $modx; |
|
| 1539 | + global $modx; |
|
| 1540 | 1540 | |
| 1541 | 1541 | $default_template = ''; |
| 1542 | - switch($modx->config['auto_template_logic']) { |
|
| 1543 | - case 'sibling': |
|
| 1544 | - if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1545 | - $site_start = $modx->config['site_start']; |
|
| 1546 | - $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1547 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1548 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1549 | - $default_template = $sibl[0]['template']; |
|
| 1550 | - } |
|
| 1551 | - } else { |
|
| 1552 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | - $default_template = $sibl[0]['template']; |
|
| 1555 | - } else { |
|
| 1556 | - $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1557 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1558 | - $default_template = $sibl[0]['template']; |
|
| 1559 | - } |
|
| 1560 | - } |
|
| 1561 | - } |
|
| 1562 | - if(isset($default_template)) { |
|
| 1563 | - break; |
|
| 1564 | - } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1565 | - case 'parent': |
|
| 1566 | - if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1567 | - $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1568 | - if(isset($parent['template'])) { |
|
| 1569 | - $default_template = $parent['template']; |
|
| 1570 | - } |
|
| 1571 | - } |
|
| 1572 | - break; |
|
| 1573 | - case 'system': |
|
| 1574 | - default: // default_template is already set |
|
| 1575 | - $default_template = $modx->config['default_template']; |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - return empty($default_template) ? $modx->config['default_template'] : $default_template; |
|
| 1542 | + switch($modx->config['auto_template_logic']) { |
|
| 1543 | + case 'sibling': |
|
| 1544 | + if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1545 | + $site_start = $modx->config['site_start']; |
|
| 1546 | + $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
|
| 1547 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
|
| 1548 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1549 | + $default_template = $sibl[0]['template']; |
|
| 1550 | + } |
|
| 1551 | + } else { |
|
| 1552 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1553 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1554 | + $default_template = $sibl[0]['template']; |
|
| 1555 | + } else { |
|
| 1556 | + $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
|
| 1557 | + if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1558 | + $default_template = $sibl[0]['template']; |
|
| 1559 | + } |
|
| 1560 | + } |
|
| 1561 | + } |
|
| 1562 | + if(isset($default_template)) { |
|
| 1563 | + break; |
|
| 1564 | + } // If $default_template could not be determined, fall back / through to "parent"-mode |
|
| 1565 | + case 'parent': |
|
| 1566 | + if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1567 | + $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
|
| 1568 | + if(isset($parent['template'])) { |
|
| 1569 | + $default_template = $parent['template']; |
|
| 1570 | + } |
|
| 1571 | + } |
|
| 1572 | + break; |
|
| 1573 | + case 'system': |
|
| 1574 | + default: // default_template is already set |
|
| 1575 | + $default_template = $modx->config['default_template']; |
|
| 1576 | + } |
|
| 1577 | + |
|
| 1578 | + return empty($default_template) ? $modx->config['default_template'] : $default_template; |
|
| 1579 | 1579 | } |
@@ -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> |
@@ -1353,7 +1355,9 @@ discard block |
||
| 1353 | 1355 | if($documentId > 0) { |
| 1354 | 1356 | // Load up, the permissions from the parent (if new document) or existing document |
| 1355 | 1357 | $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']; |
|
| 1358 | + while($currentgroup = $modx->db->getRow($rs)) { |
|
| 1359 | + $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1360 | + } |
|
| 1357 | 1361 | |
| 1358 | 1362 | // Load up the current permissions and names |
| 1359 | 1363 | $vs = array( |
@@ -1415,7 +1419,9 @@ discard block |
||
| 1415 | 1419 | |
| 1416 | 1420 | // Create attribute string list |
| 1417 | 1421 | $inputString = array(); |
| 1418 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1422 | + foreach($inputAttributes as $k => $v) { |
|
| 1423 | + $inputString[] = $k . '="' . $v . '"'; |
|
| 1424 | + } |
|
| 1419 | 1425 | |
| 1420 | 1426 | // Make the <input> HTML |
| 1421 | 1427 | $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
@@ -1535,7 +1541,8 @@ discard block |
||
| 1535 | 1541 | /** |
| 1536 | 1542 | * @return string |
| 1537 | 1543 | */ |
| 1538 | -function getDefaultTemplate() { |
|
| 1544 | +function getDefaultTemplate() |
|
| 1545 | +{ |
|
| 1539 | 1546 | global $modx; |
| 1540 | 1547 | |
| 1541 | 1548 | $default_template = ''; |
@@ -1,20 +1,20 @@ 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 | switch($modx->manager->action) {
|
| 6 | - case 107: |
|
| 7 | - if(!$modx->hasPermission('new_module')) {
|
|
| 8 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 9 | - } |
|
| 10 | - break; |
|
| 11 | - case 108: |
|
| 12 | - if(!$modx->hasPermission('edit_module')) {
|
|
| 13 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 14 | - } |
|
| 15 | - break; |
|
| 16 | - default: |
|
| 17 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + case 107: |
|
| 7 | + if(!$modx->hasPermission('new_module')) {
|
|
| 8 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 9 | + } |
|
| 10 | + break; |
|
| 11 | + case 108: |
|
| 12 | + if(!$modx->hasPermission('edit_module')) {
|
|
| 13 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 14 | + } |
|
| 15 | + break; |
|
| 16 | + default: |
|
| 17 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 18 | 18 | } |
| 19 | 19 | $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
| 20 | 20 | // Get table names (alphabetical) |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | 36 | function createGUID() {
|
| 37 | - srand((double) microtime() * 1000000); |
|
| 38 | - $r = rand(); |
|
| 39 | - $u = uniqid(getmypid() . $r . (double) microtime() * 1000000, 1); |
|
| 40 | - $m = md5($u); |
|
| 41 | - return $m; |
|
| 37 | + srand((double) microtime() * 1000000); |
|
| 38 | + $r = rand(); |
|
| 39 | + $u = uniqid(getmypid() . $r . (double) microtime() * 1000000, 1); |
|
| 40 | + $m = md5($u); |
|
| 41 | + return $m; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // check to see the module editor isn't locked |
| 45 | 45 | if($lockedEl = $modx->elementIsLocked(6, $id)) {
|
| 46 | - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module'])); |
|
| 46 | + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module'])); |
|
| 47 | 47 | } |
| 48 | 48 | // end check for lock |
| 49 | 49 | |
@@ -51,22 +51,22 @@ discard block |
||
| 51 | 51 | $modx->lockElement(6, $id); |
| 52 | 52 | |
| 53 | 53 | if(isset($_GET['id'])) {
|
| 54 | - $rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
|
|
| 55 | - $content = $modx->db->getRow($rs); |
|
| 56 | - if(!$content) {
|
|
| 57 | - $modx->webAlertAndQuit("Module not found for id '{$id}'.");
|
|
| 58 | - } |
|
| 59 | - $content['properties'] = str_replace("&", "&", $content['properties']);
|
|
| 60 | - $_SESSION['itemname'] = $content['name']; |
|
| 61 | - if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
|
|
| 62 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 63 | - } |
|
| 54 | + $rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
|
|
| 55 | + $content = $modx->db->getRow($rs); |
|
| 56 | + if(!$content) {
|
|
| 57 | + $modx->webAlertAndQuit("Module not found for id '{$id}'.");
|
|
| 58 | + } |
|
| 59 | + $content['properties'] = str_replace("&", "&", $content['properties']);
|
|
| 60 | + $_SESSION['itemname'] = $content['name']; |
|
| 61 | + if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
|
|
| 62 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 63 | + } |
|
| 64 | 64 | } else {
|
| 65 | - $_SESSION['itemname'] = $_lang["new_module"]; |
|
| 66 | - $content['wrap'] = '1'; |
|
| 65 | + $_SESSION['itemname'] = $_lang["new_module"]; |
|
| 66 | + $content['wrap'] = '1'; |
|
| 67 | 67 | } |
| 68 | 68 | if($modx->manager->hasFormValues()) {
|
| 69 | - $modx->manager->loadFormValues(); |
|
| 69 | + $modx->manager->loadFormValues(); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Add lock-element JS-Script |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | <form name="mutate" id="mutate" class="module" method="post" action="index.php?a=109"> |
| 439 | 439 | <?php |
| 440 | - // invoke OnModFormPrerender event |
|
| 441 | - $evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
|
|
| 442 | - if(is_array($evtOut)) {
|
|
| 443 | - echo implode('', $evtOut);
|
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - // Prepare internal params & info-tab via parseDocBlock |
|
| 447 | - $modulecode = isset($content['modulecode']) ? $modx->db->escape($content['modulecode']) : ''; |
|
| 448 | - $docBlock = $modx->parseDocBlockFromString($modulecode); |
|
| 449 | - $docBlockList = $modx->convertDocBlockIntoList($docBlock); |
|
| 450 | - $internal = array(); |
|
| 451 | - ?> |
|
| 440 | + // invoke OnModFormPrerender event |
|
| 441 | + $evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
|
|
| 442 | + if(is_array($evtOut)) {
|
|
| 443 | + echo implode('', $evtOut);
|
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + // Prepare internal params & info-tab via parseDocBlock |
|
| 447 | + $modulecode = isset($content['modulecode']) ? $modx->db->escape($content['modulecode']) : ''; |
|
| 448 | + $docBlock = $modx->parseDocBlockFromString($modulecode); |
|
| 449 | + $docBlockList = $modx->convertDocBlockIntoList($docBlock); |
|
| 450 | + $internal = array(); |
|
| 451 | + ?> |
|
| 452 | 452 | <input type="hidden" name="id" value="<?= $content['id'] ?>"> |
| 453 | 453 | <input type="hidden" name="mode" value="<?= $modx->manager->action ?>"> |
| 454 | 454 | |
@@ -501,11 +501,11 @@ discard block |
||
| 501 | 501 | <select name="categoryid" class="form-control" onchange="documentDirty=true;"> |
| 502 | 502 | <option> </option> |
| 503 | 503 | <?php |
| 504 | - include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 505 | - foreach(getCategories() as $n => $v) {
|
|
| 506 | - echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n"; |
|
| 507 | - } |
|
| 508 | - ?> |
|
| 504 | + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
|
| 505 | + foreach(getCategories() as $n => $v) {
|
|
| 506 | + echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n"; |
|
| 507 | + } |
|
| 508 | + ?> |
|
| 509 | 509 | </select> |
| 510 | 510 | </div> |
| 511 | 511 | </div> |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | <i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang['manage_depends'] ?></a> |
| 613 | 613 | </div> |
| 614 | 614 | <?php |
| 615 | - $ds = $modx->db->select("smd.id, COALESCE(ss.name,st.templatename,sv.name,sc.name,sp.name,sd.pagetitle) AS name,
|
|
| 615 | + $ds = $modx->db->select("smd.id, COALESCE(ss.name,st.templatename,sv.name,sc.name,sp.name,sd.pagetitle) AS name,
|
|
| 616 | 616 | CASE smd.type |
| 617 | 617 | WHEN 10 THEN 'Chunk' |
| 618 | 618 | WHEN 20 THEN 'Document' |
@@ -628,17 +628,17 @@ discard block |
||
| 628 | 628 | LEFT JOIN {$tbl_site_templates} AS st ON st.id = smd.resource AND smd.type = 50
|
| 629 | 629 | LEFT JOIN {$tbl_site_tmplvars} AS sv ON sv.id = smd.resource AND smd.type = 60", "smd.module='{$id}'", 'smd.type,name');
|
| 630 | 630 | |
| 631 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 632 | - $grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
|
|
| 633 | - $grd->noRecordMsg = $_lang['no_records_found']; |
|
| 634 | - $grd->cssClass = 'grid'; |
|
| 635 | - $grd->columnHeaderClass = 'gridHeader'; |
|
| 636 | - $grd->itemClass = 'gridItem'; |
|
| 637 | - $grd->altItemClass = 'gridAltItem'; |
|
| 638 | - $grd->columns = $_lang['element_name'] . " ," . $_lang['type']; |
|
| 639 | - $grd->fields = "name,type"; |
|
| 640 | - echo $grd->render(); |
|
| 641 | - ?> |
|
| 631 | + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 632 | + $grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
|
|
| 633 | + $grd->noRecordMsg = $_lang['no_records_found']; |
|
| 634 | + $grd->cssClass = 'grid'; |
|
| 635 | + $grd->columnHeaderClass = 'gridHeader'; |
|
| 636 | + $grd->itemClass = 'gridItem'; |
|
| 637 | + $grd->altItemClass = 'gridAltItem'; |
|
| 638 | + $grd->columns = $_lang['element_name'] . " ," . $_lang['type']; |
|
| 639 | + $grd->fields = "name,type"; |
|
| 640 | + echo $grd->render(); |
|
| 641 | + ?> |
|
| 642 | 642 | </div> |
| 643 | 643 | </div> |
| 644 | 644 | <?php endif; ?> |
@@ -650,12 +650,12 @@ discard block |
||
| 650 | 650 | <div class="container container-body"> |
| 651 | 651 | <?php if($use_udperms == 1) : ?> |
| 652 | 652 | <?php |
| 653 | - // fetch user access permissions for the module |
|
| 654 | - $rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
|
|
| 655 | - $groupsarray = $modx->db->getColumn('usergroup', $rs);
|
|
| 653 | + // fetch user access permissions for the module |
|
| 654 | + $rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
|
|
| 655 | + $groupsarray = $modx->db->getColumn('usergroup', $rs);
|
|
| 656 | 656 | |
| 657 | - if($modx->hasPermission('access_permissions')) {
|
|
| 658 | - ?> |
|
| 657 | + if($modx->hasPermission('access_permissions')) {
|
|
| 658 | + ?> |
|
| 659 | 659 | <!-- User Group Access Permissions --> |
| 660 | 660 | <script type="text/javascript"> |
| 661 | 661 | function makePublic(b) {
|
@@ -679,28 +679,28 @@ discard block |
||
| 679 | 679 | </script> |
| 680 | 680 | <p><?= $_lang['module_group_access_msg'] ?></p> |
| 681 | 681 | <?php |
| 682 | - } |
|
| 683 | - $chk = ''; |
|
| 684 | - $rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
|
|
| 685 | - while($row = $modx->db->getRow($rs)) {
|
|
| 686 | - $groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array(); |
|
| 687 | - $checked = in_array($row['id'], $groupsarray); |
|
| 688 | - if($modx->hasPermission('access_permissions')) {
|
|
| 689 | - if($checked) {
|
|
| 690 | - $notPublic = true; |
|
| 691 | - } |
|
| 692 | - $chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n"; |
|
| 693 | - } else {
|
|
| 694 | - if($checked) {
|
|
| 695 | - $chks = '<input type="hidden" name="usrgroups[]" value="' . $row['id'] . '" />' . "\n" . $chks; |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - if($modx->hasPermission('access_permissions')) {
|
|
| 700 | - $chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks; |
|
| 701 | - } |
|
| 702 | - echo $chks; |
|
| 703 | - ?> |
|
| 682 | + } |
|
| 683 | + $chk = ''; |
|
| 684 | + $rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
|
|
| 685 | + while($row = $modx->db->getRow($rs)) {
|
|
| 686 | + $groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array(); |
|
| 687 | + $checked = in_array($row['id'], $groupsarray); |
|
| 688 | + if($modx->hasPermission('access_permissions')) {
|
|
| 689 | + if($checked) {
|
|
| 690 | + $notPublic = true; |
|
| 691 | + } |
|
| 692 | + $chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n"; |
|
| 693 | + } else {
|
|
| 694 | + if($checked) {
|
|
| 695 | + $chks = '<input type="hidden" name="usrgroups[]" value="' . $row['id'] . '" />' . "\n" . $chks; |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + if($modx->hasPermission('access_permissions')) {
|
|
| 700 | + $chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks; |
|
| 701 | + } |
|
| 702 | + echo $chks; |
|
| 703 | + ?> |
|
| 704 | 704 | <?php endif; ?> |
| 705 | 705 | </div> |
| 706 | 706 | </div> |
@@ -716,11 +716,11 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | <input type="submit" name="save" style="display:none;"> |
| 718 | 718 | <?php |
| 719 | - // invoke OnModFormRender event |
|
| 720 | - $evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
|
|
| 721 | - if(is_array($evtOut)) {
|
|
| 722 | - echo implode('', $evtOut);
|
|
| 723 | - } |
|
| 724 | - ?> |
|
| 719 | + // invoke OnModFormRender event |
|
| 720 | + $evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
|
|
| 721 | + if(is_array($evtOut)) {
|
|
| 722 | + echo implode('', $evtOut);
|
|
| 723 | + } |
|
| 724 | + ?> |
|
| 725 | 725 | </form> |
| 726 | 726 | <script type="text/javascript">setTimeout('showParameters();', 10);</script>
|
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | -switch($modx->manager->action) {
|
|
| 5 | +switch($modx->manager->action) { |
|
| 6 | 6 | case 107: |
| 7 | - if(!$modx->hasPermission('new_module')) {
|
|
| 7 | + if(!$modx->hasPermission('new_module')) { |
|
| 8 | 8 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 9 | 9 | } |
| 10 | 10 | break; |
| 11 | 11 | case 108: |
| 12 | - if(!$modx->hasPermission('edit_module')) {
|
|
| 12 | + if(!$modx->hasPermission('edit_module')) { |
|
| 13 | 13 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 14 | 14 | } |
| 15 | 15 | break; |
@@ -33,7 +33,8 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | -function createGUID() {
|
|
| 36 | +function createGUID() |
|
| 37 | +{ |
|
| 37 | 38 | srand((double) microtime() * 1000000); |
| 38 | 39 | $r = rand(); |
| 39 | 40 | $u = uniqid(getmypid() . $r . (double) microtime() * 1000000, 1); |
@@ -42,7 +43,7 @@ discard block |
||
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | // check to see the module editor isn't locked |
| 45 | -if($lockedEl = $modx->elementIsLocked(6, $id)) {
|
|
| 46 | +if($lockedEl = $modx->elementIsLocked(6, $id)) { |
|
| 46 | 47 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['module'])); |
| 47 | 48 | } |
| 48 | 49 | // end check for lock |
@@ -50,22 +51,22 @@ discard block |
||
| 50 | 51 | // Lock snippet for other users to edit |
| 51 | 52 | $modx->lockElement(6, $id); |
| 52 | 53 | |
| 53 | -if(isset($_GET['id'])) {
|
|
| 54 | +if(isset($_GET['id'])) { |
|
| 54 | 55 | $rs = $modx->db->select('*', $tbl_site_modules, "id='{$id}'");
|
| 55 | 56 | $content = $modx->db->getRow($rs); |
| 56 | - if(!$content) {
|
|
| 57 | + if(!$content) { |
|
| 57 | 58 | $modx->webAlertAndQuit("Module not found for id '{$id}'.");
|
| 58 | 59 | } |
| 59 | 60 | $content['properties'] = str_replace("&", "&", $content['properties']);
|
| 60 | 61 | $_SESSION['itemname'] = $content['name']; |
| 61 | - if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
|
|
| 62 | + if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { |
|
| 62 | 63 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 63 | 64 | } |
| 64 | -} else {
|
|
| 65 | +} else { |
|
| 65 | 66 | $_SESSION['itemname'] = $_lang["new_module"]; |
| 66 | 67 | $content['wrap'] = '1'; |
| 67 | 68 | } |
| 68 | -if($modx->manager->hasFormValues()) {
|
|
| 69 | +if($modx->manager->hasFormValues()) { |
|
| 69 | 70 | $modx->manager->loadFormValues(); |
| 70 | 71 | } |
| 71 | 72 | |
@@ -439,7 +440,7 @@ discard block |
||
| 439 | 440 | <?php |
| 440 | 441 | // invoke OnModFormPrerender event |
| 441 | 442 | $evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
|
| 442 | - if(is_array($evtOut)) {
|
|
| 443 | + if(is_array($evtOut)) { |
|
| 443 | 444 | echo implode('', $evtOut);
|
| 444 | 445 | } |
| 445 | 446 | |
@@ -502,7 +503,7 @@ discard block |
||
| 502 | 503 | <option> </option> |
| 503 | 504 | <?php |
| 504 | 505 | include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); |
| 505 | - foreach(getCategories() as $n => $v) {
|
|
| 506 | + foreach(getCategories() as $n => $v) { |
|
| 506 | 507 | echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n"; |
| 507 | 508 | } |
| 508 | 509 | ?> |
@@ -654,7 +655,7 @@ discard block |
||
| 654 | 655 | $rs = $modx->db->select('usergroup', $tbl_site_module_access, "module='{$id}'");
|
| 655 | 656 | $groupsarray = $modx->db->getColumn('usergroup', $rs);
|
| 656 | 657 | |
| 657 | - if($modx->hasPermission('access_permissions')) {
|
|
| 658 | + if($modx->hasPermission('access_permissions')) { |
|
| 658 | 659 | ?> |
| 659 | 660 | <!-- User Group Access Permissions --> |
| 660 | 661 | <script type="text/javascript"> |
@@ -682,21 +683,21 @@ discard block |
||
| 682 | 683 | } |
| 683 | 684 | $chk = ''; |
| 684 | 685 | $rs = $modx->db->select('name, id', $tbl_membergroup_names, '', 'name');
|
| 685 | - while($row = $modx->db->getRow($rs)) {
|
|
| 686 | + while($row = $modx->db->getRow($rs)) { |
|
| 686 | 687 | $groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array(); |
| 687 | 688 | $checked = in_array($row['id'], $groupsarray); |
| 688 | - if($modx->hasPermission('access_permissions')) {
|
|
| 689 | - if($checked) {
|
|
| 689 | + if($modx->hasPermission('access_permissions')) { |
|
| 690 | + if($checked) { |
|
| 690 | 691 | $notPublic = true; |
| 691 | 692 | } |
| 692 | 693 | $chks .= '<label><input type="checkbox" name="usrgroups[]" value="' . $row['id'] . '"' . ($checked ? ' checked="checked"' : '') . ' onclick="makePublic(false)" /> ' . $row['name'] . "</label><br />\n"; |
| 693 | - } else {
|
|
| 694 | - if($checked) {
|
|
| 694 | + } else { |
|
| 695 | + if($checked) { |
|
| 695 | 696 | $chks = '<input type="hidden" name="usrgroups[]" value="' . $row['id'] . '" />' . "\n" . $chks; |
| 696 | 697 | } |
| 697 | 698 | } |
| 698 | 699 | } |
| 699 | - if($modx->hasPermission('access_permissions')) {
|
|
| 700 | + if($modx->hasPermission('access_permissions')) { |
|
| 700 | 701 | $chks = '<label><input type="checkbox" name="chkallgroups"' . (!$notPublic ? ' checked="checked"' : '') . ' onclick="makePublic(true)" /><span class="warning"> ' . $_lang['all_usr_groups'] . '</span></label><br />' . "\n" . $chks; |
| 701 | 702 | } |
| 702 | 703 | echo $chks; |
@@ -718,7 +719,7 @@ discard block |
||
| 718 | 719 | <?php |
| 719 | 720 | // invoke OnModFormRender event |
| 720 | 721 | $evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
|
| 721 | - if(is_array($evtOut)) {
|
|
| 722 | + if(is_array($evtOut)) { |
|
| 722 | 723 | echo implode('', $evtOut);
|
| 723 | 724 | } |
| 724 | 725 | ?> |