@@ -414,6 +414,9 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | + /** |
|
| 418 | + * @param string $table |
|
| 419 | + */ |
|
| 417 | 420 | public function save($fields, $table, $where = '') |
| 418 | 421 | { |
| 419 | 422 | |
@@ -444,6 +447,7 @@ discard block |
||
| 444 | 447 | /** |
| 445 | 448 | * @name: freeResult |
| 446 | 449 | * |
| 450 | + * @param mysqli_result $rs |
|
| 447 | 451 | */ |
| 448 | 452 | public function freeResult($rs) |
| 449 | 453 | { |
@@ -554,6 +558,7 @@ discard block |
||
| 554 | 558 | * @name: getColumn |
| 555 | 559 | * @desc: returns an array of the values found on colun $name |
| 556 | 560 | * @param: $dsq - dataset or query string |
| 561 | + * @param string $name |
|
| 557 | 562 | */ |
| 558 | 563 | public function getColumn($name, $dsq) |
| 559 | 564 | { |
@@ -720,6 +725,9 @@ discard block |
||
| 720 | 725 | return $result; |
| 721 | 726 | } |
| 722 | 727 | |
| 728 | + /** |
|
| 729 | + * @param string $table_name |
|
| 730 | + */ |
|
| 723 | 731 | public function optimize($table_name) |
| 724 | 732 | { |
| 725 | 733 | $rs = $this->query("OPTIMIZE TABLE {$table_name}"); |
@@ -730,6 +738,9 @@ discard block |
||
| 730 | 738 | return $rs; |
| 731 | 739 | } |
| 732 | 740 | |
| 741 | + /** |
|
| 742 | + * @param string $table_name |
|
| 743 | + */ |
|
| 733 | 744 | public function truncate($table_name) |
| 734 | 745 | { |
| 735 | 746 | $rs = $this->query("TRUNCATE {$table_name}"); |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | case 'publishedon': |
| 39 | 39 | case 'pub_date': |
| 40 | 40 | case 'unpub_date': |
| 41 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
| 41 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
| 42 | 42 | break; |
| 43 | 43 | default: |
| 44 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
| 44 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
| 47 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
| 48 | 48 | |
| 49 | 49 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
| 50 | 50 | if ($_SESSION['tree_sortby'] == 'isfolder') { |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
| 59 | 59 | $showProtected = false; |
| 60 | 60 | if (isset ($modx->config['tree_show_protected'])) { |
| 61 | - $showProtected = (boolean)$modx->config['tree_show_protected']; |
|
| 61 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
| 62 | 62 | } |
| 63 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string)$_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 63 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
| 64 | 64 | if ($showProtected == false) { |
| 65 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 65 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
| 66 | 66 | } else { |
| 67 | 67 | $access = ''; |
| 68 | 68 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
| 101 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
| 101 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
| 102 | 102 | |
| 103 | 103 | // Prepare displaying user-locks |
| 104 | 104 | $lockedByUser = ''; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | 'element_type' => $_lang["lock_element_type_7"], |
| 110 | 110 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 111 | 111 | )); |
| 112 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
| 112 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
| 113 | 113 | } else { |
| 114 | 114 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
| 115 | 115 | 'element_type' => $_lang["lock_element_type_7"], |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 118 | 118 | )); |
| 119 | 119 | if ($modx->hasPermission('remove_locks')) { |
| 120 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 120 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 121 | 121 | } else { |
| 122 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
| 122 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -128,22 +128,22 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $title = ''; |
| 130 | 130 | if (isDateNode($nodeNameSource)) { |
| 131 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
| 131 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
| 132 | 132 | } |
| 133 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
| 134 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
| 135 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
| 136 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 137 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
| 138 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
| 139 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
| 140 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 141 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 142 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 143 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 144 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 133 | + $title .= $_lang['id'].': '.$row['id']; |
|
| 134 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle']; |
|
| 135 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex']; |
|
| 136 | + $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-'); |
|
| 137 | + $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename']; |
|
| 138 | + $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']); |
|
| 139 | + $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']); |
|
| 140 | + $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
| 141 | + $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
| 142 | + $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 143 | + $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 144 | + $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
| 145 | 145 | $title = $modx->htmlspecialchars($title); |
| 146 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 146 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
| 147 | 147 | |
| 148 | 148 | $data = array( |
| 149 | 149 | 'id' => $row['id'], |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ($ph['contextmenu']) { |
| 230 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 230 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | if ($_SESSION['tree_show_only_folders']) { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | if ($ph['contextmenu']) { |
| 288 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 288 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $node .= $modx->parseText($tpl, $ph); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if ($ph['contextmenu']) { |
| 326 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 326 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $node .= $modx->parseText($tpl, $ph); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | if ($ph['contextmenu']) { |
| 377 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 377 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | $node .= $modx->parseText($tpl, $ph); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | if ($ph['contextmenu']) { |
| 419 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
| 419 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $node .= $modx->parseText($tpl, $ph); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $nodetitle .= $modx->config['friendly_url_suffix']; |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
| 496 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
| 497 | 497 | break; |
| 498 | 498 | case 'pagetitle': |
| 499 | 499 | $nodetitle = $row['pagetitle']; |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | { |
| 554 | 554 | $modx = evolutionCMS(); |
| 555 | 555 | |
| 556 | - return (int)$modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
| 556 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' ')); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
@@ -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 | - $modx = evolutionCMS(); |
|
| 1539 | + $modx = evolutionCMS(); |
|
| 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 | $modx = evolutionCMS(); |
| 1540 | 1547 | |
| 1541 | 1548 | $default_template = ''; |
@@ -1,35 +1,35 @@ 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 | |
| 6 | 6 | /********************/ |
| 7 | -$sd = isset($_REQUEST['dir']) ? '&dir=' . $_REQUEST['dir'] : '&dir=DESC'; |
|
| 8 | -$sb = isset($_REQUEST['sort']) ? '&sort=' . $_REQUEST['sort'] : '&sort=createdon'; |
|
| 9 | -$pg = isset($_REQUEST['page']) ? '&page=' . (int) $_REQUEST['page'] : ''; |
|
| 10 | -$add_path = $sd . $sb . $pg; |
|
| 7 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
| 8 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
| 9 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
| 10 | +$add_path = $sd.$sb.$pg; |
|
| 11 | 11 | /*******************/ |
| 12 | 12 | |
| 13 | 13 | // check permissions |
| 14 | -switch($modx->manager->action) { |
|
| 14 | +switch ($modx->manager->action) { |
|
| 15 | 15 | case 27: |
| 16 | - if(!$modx->hasPermission('edit_document')) { |
|
| 16 | + if (!$modx->hasPermission('edit_document')) { |
|
| 17 | 17 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 18 | 18 | } |
| 19 | 19 | break; |
| 20 | 20 | case 85: |
| 21 | 21 | case 72: |
| 22 | 22 | case 4: |
| 23 | - if(!$modx->hasPermission('new_document')) { |
|
| 23 | + if (!$modx->hasPermission('new_document')) { |
|
| 24 | 24 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 25 | - } elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 25 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '0') { |
|
| 26 | 26 | // check user has permissions for parent |
| 27 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 27 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 28 | 28 | $udperms = new udperms(); |
| 29 | 29 | $udperms->user = $modx->getLoginUserID(); |
| 30 | 30 | $udperms->document = empty($_REQUEST['pid']) ? 0 : $_REQUEST['pid']; |
| 31 | 31 | $udperms->role = $_SESSION['mgrRole']; |
| 32 | - if(!$udperms->checkPermissions()) { |
|
| 32 | + if (!$udperms->checkPermissions()) { |
|
| 33 | 33 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 41 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 42 | 42 | |
| 43 | 43 | // Get table names (alphabetical) |
| 44 | 44 | $tbl_categories = $modx->getFullTableName('categories'); |
@@ -53,22 +53,22 @@ discard block |
||
| 53 | 53 | $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates'); |
| 54 | 54 | $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars'); |
| 55 | 55 | |
| 56 | -if($modx->manager->action == 27) { |
|
| 56 | +if ($modx->manager->action == 27) { |
|
| 57 | 57 | //editing an existing document |
| 58 | 58 | // check permissions on the document |
| 59 | - include_once(MODX_MANAGER_PATH . 'processors/user_documents_permissions.class.php'); |
|
| 59 | + include_once(MODX_MANAGER_PATH.'processors/user_documents_permissions.class.php'); |
|
| 60 | 60 | $udperms = new udperms(); |
| 61 | 61 | $udperms->user = $modx->getLoginUserID(); |
| 62 | 62 | $udperms->document = $id; |
| 63 | 63 | $udperms->role = $_SESSION['mgrRole']; |
| 64 | 64 | |
| 65 | - if(!$udperms->checkPermissions()) { |
|
| 65 | + if (!$udperms->checkPermissions()) { |
|
| 66 | 66 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // check to see if resource isn't locked |
| 71 | -if($lockedEl = $modx->elementIsLocked(7, $id)) { |
|
| 71 | +if ($lockedEl = $modx->elementIsLocked(7, $id)) { |
|
| 72 | 72 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['resource'])); |
| 73 | 73 | } |
| 74 | 74 | // end check for lock |
@@ -77,27 +77,27 @@ discard block |
||
| 77 | 77 | $modx->lockElement(7, $id); |
| 78 | 78 | |
| 79 | 79 | // get document groups for current user |
| 80 | -if($_SESSION['mgrDocgroups']) { |
|
| 80 | +if ($_SESSION['mgrDocgroups']) { |
|
| 81 | 81 | $docgrp = implode(',', $_SESSION['mgrDocgroups']); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -if(!empty ($id)) { |
|
| 84 | +if (!empty ($id)) { |
|
| 85 | 85 | $access = sprintf("1='%s' OR sc.privatemgr=0", $_SESSION['mgrRole']); |
| 86 | - if($docgrp) { |
|
| 86 | + if ($docgrp) { |
|
| 87 | 87 | $access .= " OR dg.document_group IN ({$docgrp})"; |
| 88 | 88 | } |
| 89 | 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 | 90 | $content = array(); |
| 91 | 91 | $content = $modx->db->getRow($rs); |
| 92 | 92 | $modx->documentObject = &$content; |
| 93 | - if(!$content) { |
|
| 93 | + if (!$content) { |
|
| 94 | 94 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 95 | 95 | } |
| 96 | 96 | $_SESSION['itemname'] = $content['pagetitle']; |
| 97 | 97 | } else { |
| 98 | 98 | $content = array(); |
| 99 | 99 | |
| 100 | - if(isset($_REQUEST['newtemplate'])) { |
|
| 100 | + if (isset($_REQUEST['newtemplate'])) { |
|
| 101 | 101 | $content['template'] = $_REQUEST['newtemplate']; |
| 102 | 102 | } else { |
| 103 | 103 | $content['template'] = getDefaultTemplate(); |
@@ -108,22 +108,22 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // restore saved form |
| 110 | 110 | $formRestored = $modx->manager->loadFormValues(); |
| 111 | -if(isset($_REQUEST['newtemplate'])) { |
|
| 111 | +if (isset($_REQUEST['newtemplate'])) { |
|
| 112 | 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 | -if($formRestored == true) { |
|
| 118 | +if ($formRestored == true) { |
|
| 119 | 119 | $content = array_merge($content, $_POST); |
| 120 | 120 | $content['content'] = $_POST['ta']; |
| 121 | - if(empty ($content['pub_date'])) { |
|
| 121 | + if (empty ($content['pub_date'])) { |
|
| 122 | 122 | unset ($content['pub_date']); |
| 123 | 123 | } else { |
| 124 | 124 | $content['pub_date'] = $modx->toTimeStamp($content['pub_date']); |
| 125 | 125 | } |
| 126 | - if(empty ($content['unpub_date'])) { |
|
| 126 | + if (empty ($content['unpub_date'])) { |
|
| 127 | 127 | unset ($content['unpub_date']); |
| 128 | 128 | } else { |
| 129 | 129 | $content['unpub_date'] = $modx->toTimeStamp($content['unpub_date']); |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // increase menu index if this is a new document |
| 134 | -if(!isset ($_REQUEST['id'])) { |
|
| 135 | - if(!isset ($modx->config['auto_menuindex'])) { |
|
| 134 | +if (!isset ($_REQUEST['id'])) { |
|
| 135 | + if (!isset ($modx->config['auto_menuindex'])) { |
|
| 136 | 136 | $modx->config['auto_menuindex'] = 1; |
| 137 | 137 | } |
| 138 | - if($modx->config['auto_menuindex']) { |
|
| 139 | - $pid = (int)$_REQUEST['pid']; |
|
| 138 | + if ($modx->config['auto_menuindex']) { |
|
| 139 | + $pid = (int) $_REQUEST['pid']; |
|
| 140 | 140 | $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); |
| 141 | 141 | $content['menuindex'] = $modx->db->getValue($rs); |
| 142 | 142 | } else { |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -if(isset ($_POST['which_editor'])) { |
|
| 147 | +if (isset ($_POST['which_editor'])) { |
|
| 148 | 148 | $modx->config['which_editor'] = $_POST['which_editor']; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Add lock-element JS-Script |
| 152 | 152 | $lockElementId = $id; |
| 153 | 153 | $lockElementType = 7; |
| 154 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
| 154 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
| 155 | 155 | ?> |
| 156 | 156 | <script type="text/javascript"> |
| 157 | 157 | /* <![CDATA[ */ |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | }, |
| 182 | 182 | cancel: function() { |
| 183 | 183 | documentDirty = false; |
| 184 | - document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id=' . $id . $add_path) ?>'; |
|
| 184 | + document.location.href = 'index.php?<?=($id == 0 ? 'a=2' : 'a=3&r=1&id='.$id.$add_path) ?>'; |
|
| 185 | 185 | }, |
| 186 | 186 | duplicate: function() { |
| 187 | 187 | if(confirm("<?= $_lang['confirm_resource_duplicate']?>") === true) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | }, |
| 191 | 191 | view: function() { |
| 192 | - window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'] . 'index.php?id=' . $id ?>', 'previeWin'); |
|
| 192 | + window.open('<?= ($modx->config['friendly_urls'] == '1') ? $modx->makeUrl($id) : $modx->config['site_url'].'index.php?id='.$id ?>', 'previeWin'); |
|
| 193 | 193 | } |
| 194 | 194 | }; |
| 195 | 195 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | 'template' => $content['template'] |
| 552 | 552 | )); |
| 553 | 553 | |
| 554 | - if(is_array($evtOut)) { |
|
| 554 | + if (is_array($evtOut)) { |
|
| 555 | 555 | echo implode('', $evtOut); |
| 556 | 556 | } |
| 557 | 557 | |
@@ -575,8 +575,8 @@ discard block |
||
| 575 | 575 | <fieldset id="create_edit"> |
| 576 | 576 | |
| 577 | 577 | <h1> |
| 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>'; |
|
| 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 | 580 | } else { |
| 581 | 581 | if ($modx->manager->action == '4') { |
| 582 | 582 | echo $_lang['add_resource']; |
@@ -592,36 +592,36 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | <?php |
| 594 | 594 | // breadcrumbs |
| 595 | - if($modx->config['use_breadcrumbs']) { |
|
| 595 | + if ($modx->config['use_breadcrumbs']) { |
|
| 596 | 596 | $temp = array(); |
| 597 | 597 | $title = isset($content['pagetitle']) ? $content['pagetitle'] : $_lang['create_resource_title']; |
| 598 | 598 | |
| 599 | - if(isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 599 | + if (isset($_REQUEST['id']) && $content['parent'] != 0) { |
|
| 600 | 600 | $bID = (int) $_REQUEST['id']; |
| 601 | 601 | $temp = $modx->getParentIds($bID); |
| 602 | - } else if(isset($_REQUEST['pid'])) { |
|
| 602 | + } else if (isset($_REQUEST['pid'])) { |
|
| 603 | 603 | $bID = (int) $_REQUEST['pid']; |
| 604 | 604 | $temp = $modx->getParentIds($bID); |
| 605 | 605 | array_unshift($temp, $bID); |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - if($temp) { |
|
| 608 | + if ($temp) { |
|
| 609 | 609 | $parents = implode(',', $temp); |
| 610 | 610 | |
| 611 | - if(!empty($parents)) { |
|
| 611 | + if (!empty($parents)) { |
|
| 612 | 612 | $where = "FIND_IN_SET(id,'{$parents}') DESC"; |
| 613 | 613 | $rs = $modx->db->select('id, pagetitle', $tbl_site_content, "id IN ({$parents})", $where); |
| 614 | - while($row = $modx->db->getRow($rs)) { |
|
| 614 | + while ($row = $modx->db->getRow($rs)) { |
|
| 615 | 615 | $out .= '<li class="breadcrumbs__li"> |
| 616 | - <a href="index.php?a=27&id=' . $row['id'] . '" class="breadcrumbs__a">' . htmlspecialchars($row['pagetitle'], ENT_QUOTES, $modx->config['modx_charset']) . '</a> |
|
| 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 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">' . $title . '</li>'; |
|
| 624 | - echo '<ul class="breadcrumbs">' . $out . '</ul>'; |
|
| 623 | + $out .= '<li class="breadcrumbs__li breadcrumbs__li_current">'.$title.'</li>'; |
|
| 624 | + echo '<ul class="breadcrumbs">'.$out.'</ul>'; |
|
| 625 | 625 | } |
| 626 | 626 | ?> |
| 627 | 627 | |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $evtOut = $modx->invokeEvent('OnDocFormTemplateRender', array( |
| 639 | 639 | 'id' => $id |
| 640 | 640 | )); |
| 641 | - if(is_array($evtOut)) { |
|
| 641 | + if (is_array($evtOut)) { |
|
| 642 | 642 | echo implode('', $evtOut); |
| 643 | 643 | } else { |
| 644 | 644 | ?> |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | </td> |
| 695 | 695 | </tr> |
| 696 | 696 | |
| 697 | - <?php if($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 697 | + <?php if ($content['type'] == 'reference' || $modx->manager->action == '72') { // Web Link specific ?> |
|
| 698 | 698 | |
| 699 | 699 | <tr> |
| 700 | 700 | <td><span class="warning"><?= $_lang['weblink'] ?></span> |
@@ -730,17 +730,17 @@ discard block |
||
| 730 | 730 | $from = "{$tbl_site_templates} AS t LEFT JOIN {$tbl_categories} AS c ON t.category = c.id"; |
| 731 | 731 | $rs = $modx->db->select($field, $from, '', 'c.category, t.templatename ASC'); |
| 732 | 732 | $currentCategory = ''; |
| 733 | - while($row = $modx->db->getRow($rs)) { |
|
| 734 | - if($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 733 | + while ($row = $modx->db->getRow($rs)) { |
|
| 734 | + if ($row['selectable'] != 1 && $row['id'] != $content['template']) { |
|
| 735 | 735 | continue; |
| 736 | 736 | }; |
| 737 | 737 | // Skip if not selectable but show if selected! |
| 738 | 738 | $thisCategory = $row['category']; |
| 739 | - if($thisCategory == null) { |
|
| 739 | + if ($thisCategory == null) { |
|
| 740 | 740 | $thisCategory = $_lang["no_category"]; |
| 741 | 741 | } |
| 742 | - if($thisCategory != $currentCategory) { |
|
| 743 | - if($closeOptGroup) { |
|
| 742 | + if ($thisCategory != $currentCategory) { |
|
| 743 | + if ($closeOptGroup) { |
|
| 744 | 744 | echo "\t\t\t\t\t</optgroup>\n"; |
| 745 | 745 | } |
| 746 | 746 | echo "\t\t\t\t\t<optgroup label=\"$thisCategory\">\n"; |
@@ -749,10 +749,10 @@ discard block |
||
| 749 | 749 | |
| 750 | 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"; |
|
| 752 | + echo "\t\t\t\t\t".'<option value="'.$row['id'].'"'.$selectedtext.'>'.$row['templatename']."</option>\n"; |
|
| 753 | 753 | $currentCategory = $thisCategory; |
| 754 | 754 | } |
| 755 | - if($thisCategory != '') { |
|
| 755 | + if ($thisCategory != '') { |
|
| 756 | 756 | echo "\t\t\t\t\t</optgroup>\n"; |
| 757 | 757 | } |
| 758 | 758 | ?> |
@@ -796,20 +796,20 @@ discard block |
||
| 796 | 796 | <td valign="top"> |
| 797 | 797 | <?php |
| 798 | 798 | $parentlookup = false; |
| 799 | - if(isset ($_REQUEST['id'])) { |
|
| 800 | - if($content['parent'] == 0) { |
|
| 799 | + if (isset ($_REQUEST['id'])) { |
|
| 800 | + if ($content['parent'] == 0) { |
|
| 801 | 801 | $parentname = $site_name; |
| 802 | 802 | } else { |
| 803 | 803 | $parentlookup = $content['parent']; |
| 804 | 804 | } |
| 805 | - } elseif(isset ($_REQUEST['pid'])) { |
|
| 806 | - if($_REQUEST['pid'] == 0) { |
|
| 805 | + } elseif (isset ($_REQUEST['pid'])) { |
|
| 806 | + if ($_REQUEST['pid'] == 0) { |
|
| 807 | 807 | $parentname = $site_name; |
| 808 | 808 | } else { |
| 809 | 809 | $parentlookup = $_REQUEST['pid']; |
| 810 | 810 | } |
| 811 | - } elseif(isset($_POST['parent'])) { |
|
| 812 | - if($_POST['parent'] == 0) { |
|
| 811 | + } elseif (isset($_POST['parent'])) { |
|
| 812 | + if ($_POST['parent'] == 0) { |
|
| 813 | 813 | $parentname = $site_name; |
| 814 | 814 | } else { |
| 815 | 815 | $parentlookup = $_POST['parent']; |
@@ -818,10 +818,10 @@ discard block |
||
| 818 | 818 | $parentname = $site_name; |
| 819 | 819 | $content['parent'] = 0; |
| 820 | 820 | } |
| 821 | - if($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 821 | + if ($parentlookup !== false && is_numeric($parentlookup)) { |
|
| 822 | 822 | $rs = $modx->db->select('pagetitle', $tbl_site_content, "id='{$parentlookup}'"); |
| 823 | 823 | $parentname = $modx->db->getValue($rs); |
| 824 | - if(!$parentname) { |
|
| 824 | + if (!$parentname) { |
|
| 825 | 825 | $modx->webAlertAndQuit($_lang["error_no_parent"]); |
| 826 | 826 | } |
| 827 | 827 | } |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | }*/ |
| 864 | 864 | ?> |
| 865 | 865 | |
| 866 | - <?php if($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
|
| 866 | + <?php if ($content['type'] == 'document' || $modx->manager->action == '4') { ?> |
|
| 867 | 867 | <tr> |
| 868 | 868 | <td colspan="2"> |
| 869 | 869 | <hr> |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | <?php |
| 877 | 877 | // invoke OnRichTextEditorRegister event |
| 878 | 878 | $evtOut = $modx->invokeEvent("OnRichTextEditorRegister"); |
| 879 | - if(is_array($evtOut)) { |
|
| 880 | - for($i = 0; $i < count($evtOut); $i++) { |
|
| 879 | + if (is_array($evtOut)) { |
|
| 880 | + for ($i = 0; $i < count($evtOut); $i++) { |
|
| 881 | 881 | $editor = $evtOut[$i]; |
| 882 | 882 | echo "\t\t\t", '<option value="', $editor, '"', ($modx->config['which_editor'] == $editor ? ' selected="selected"' : ''), '>', $editor, "</option>\n"; |
| 883 | 883 | } |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | </div> |
| 889 | 889 | <div id="content_body"> |
| 890 | 890 | <?php |
| 891 | - if(($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 891 | + if (($content['richtext'] == 1 || $modx->manager->action == '4') && $use_editor == 1) { |
|
| 892 | 892 | $htmlContent = $content['content']; |
| 893 | 893 | ?> |
| 894 | 894 | <div class="section-editor clearfix"> |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | $richtexteditorIds[$modx->config['which_editor']][] = 'ta'; |
| 902 | 902 | $richtexteditorOptions[$modx->config['which_editor']]['ta'] = ''; |
| 903 | 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"; |
|
| 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 | 905 | } |
| 906 | 906 | ?> |
| 907 | 907 | </div> |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | if (($content['type'] == 'document' || $modx->manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) { |
| 919 | 919 | $template = $default_template; |
| 920 | - $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs']; |
|
| 920 | + $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int) $modx->config['group_tvs']; |
|
| 921 | 921 | if (isset ($_REQUEST['newtemplate'])) { |
| 922 | 922 | $template = $_REQUEST['newtemplate']; |
| 923 | 923 | } else { |
@@ -945,17 +945,17 @@ discard block |
||
| 945 | 945 | ); |
| 946 | 946 | $sort = 'tvtpl.rank,tv.rank, tv.id'; |
| 947 | 947 | if ($group_tvs) { |
| 948 | - $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank'; |
|
| 948 | + $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"'.$_lang['no_category'].'") AS category, IFNULL(cat.rank,0) AS category_rank'; |
|
| 949 | 949 | $from .= ' |
| 950 | - LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category'; |
|
| 951 | - $sort = 'cat.rank,cat.id,' . $sort; |
|
| 950 | + LEFT JOIN ' . $tbl_categories.' AS cat ON cat.id=tv.category'; |
|
| 951 | + $sort = 'cat.rank,cat.id,'.$sort; |
|
| 952 | 952 | } |
| 953 | 953 | $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs); |
| 954 | 954 | $rs = $modx->db->select($field, $from, $where, $sort); |
| 955 | 955 | if ($modx->db->getRecordCount($rs)) { |
| 956 | 956 | $tvsArray = $modx->db->makeArray($rs, 'name'); |
| 957 | - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php'); |
|
| 958 | - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); |
|
| 957 | + require_once(MODX_MANAGER_PATH.'includes/tmplvars.inc.php'); |
|
| 958 | + require_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php'); |
|
| 959 | 959 | |
| 960 | 960 | $templateVariablesOutput = ''; |
| 961 | 961 | $templateVariablesGeneral = ''; |
@@ -969,8 +969,8 @@ discard block |
||
| 969 | 969 | if ($group_tvs == 1 || $group_tvs == 3) { |
| 970 | 970 | if ($i === 0) { |
| 971 | 971 | $templateVariablesOutput .= ' |
| 972 | - <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
|
| 973 | - <div class="tab-header">' . $row['category'] . '</div> |
|
| 972 | + <div class="tab-section" id="tabTV_' . $row['category_id'].'"> |
|
| 973 | + <div class="tab-header">' . $row['category'].'</div> |
|
| 974 | 974 | <div class="tab-body tmplvars"> |
| 975 | 975 | <table>' . "\n"; |
| 976 | 976 | } else { |
@@ -979,17 +979,17 @@ discard block |
||
| 979 | 979 | </div> |
| 980 | 980 | </div> |
| 981 | 981 | |
| 982 | - <div class="tab-section" id="tabTV_' . $row['category_id'] . '"> |
|
| 983 | - <div class="tab-header">' . $row['category'] . '</div> |
|
| 982 | + <div class="tab-section" id="tabTV_' . $row['category_id'].'"> |
|
| 983 | + <div class="tab-header">' . $row['category'].'</div> |
|
| 984 | 984 | <div class="tab-body tmplvars"> |
| 985 | 985 | <table>'; |
| 986 | 986 | } |
| 987 | 987 | } else if ($group_tvs == 2 || $group_tvs == 4) { |
| 988 | 988 | if ($i === 0) { |
| 989 | 989 | $templateVariablesOutput .= ' |
| 990 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 991 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 992 | - <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 990 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 991 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 992 | + <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 993 | 993 | |
| 994 | 994 | <div class="tab-body tmplvars"> |
| 995 | 995 | <table>'; |
@@ -999,9 +999,9 @@ discard block |
||
| 999 | 999 | </div> |
| 1000 | 1000 | </div> |
| 1001 | 1001 | |
| 1002 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1003 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1004 | - <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1002 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1003 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1004 | + <script type="text/javascript">tpTemplateVariables.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1005 | 1005 | |
| 1006 | 1006 | <div class="tab-body tmplvars"> |
| 1007 | 1007 | <table>'; |
@@ -1009,18 +1009,18 @@ discard block |
||
| 1009 | 1009 | } else if ($group_tvs == 5) { |
| 1010 | 1010 | if ($i === 0) { |
| 1011 | 1011 | $templateVariablesOutput .= ' |
| 1012 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1013 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1014 | - <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1012 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1013 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1014 | + <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1015 | 1015 | <table>'; |
| 1016 | 1016 | } else { |
| 1017 | 1017 | $templateVariablesOutput .= ' |
| 1018 | 1018 | </table> |
| 1019 | 1019 | </div> |
| 1020 | 1020 | |
| 1021 | - <div id="tabTV_' . $row['category_id'] . '" class="tab-page tmplvars"> |
|
| 1022 | - <h2 class="tab">' . $row['category'] . '</h2> |
|
| 1023 | - <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'] . '\'));</script> |
|
| 1021 | + <div id="tabTV_' . $row['category_id'].'" class="tab-page tmplvars"> |
|
| 1022 | + <h2 class="tab">' . $row['category'].'</h2> |
|
| 1023 | + <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'tabTV_' . $row['category_id'].'\'));</script> |
|
| 1024 | 1024 | |
| 1025 | 1025 | <table>'; |
| 1026 | 1026 | } |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor']; |
| 1041 | 1041 | }; |
| 1042 | 1042 | // Add richtext editor to the list |
| 1043 | - $richtexteditorIds[$editor][] = "tv" . $row['id']; |
|
| 1044 | - $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions; |
|
| 1043 | + $richtexteditorIds[$editor][] = "tv".$row['id']; |
|
| 1044 | + $richtexteditorOptions[$editor]["tv".$row['id']] = $tvOptions; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | $templateVariablesTmp = ''; |
@@ -1058,24 +1058,24 @@ discard block |
||
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | // post back value |
| 1061 | - if (array_key_exists('tv' . $row['id'], $_POST)) { |
|
| 1062 | - if (is_array($_POST['tv' . $row['id']])) { |
|
| 1063 | - $tvPBV = implode('||', $_POST['tv' . $row['id']]); |
|
| 1061 | + if (array_key_exists('tv'.$row['id'], $_POST)) { |
|
| 1062 | + if (is_array($_POST['tv'.$row['id']])) { |
|
| 1063 | + $tvPBV = implode('||', $_POST['tv'.$row['id']]); |
|
| 1064 | 1064 | } else { |
| 1065 | - $tvPBV = $_POST['tv' . $row['id']]; |
|
| 1065 | + $tvPBV = $_POST['tv'.$row['id']]; |
|
| 1066 | 1066 | } |
| 1067 | 1067 | } else { |
| 1068 | 1068 | $tvPBV = $row['value']; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | - $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">' . $row['description'] . '</span>' : ''; |
|
| 1072 | - $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">(' . $_lang['tmplvars_inherited'] . ')</span>' : ''; |
|
| 1073 | - $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*' . $row['name'] . '*]</small>' : ''; |
|
| 1071 | + $tvDescription = (!empty($row['description'])) ? '<br /><span class="comment">'.$row['description'].'</span>' : ''; |
|
| 1072 | + $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '<br /><span class="comment inherited">('.$_lang['tmplvars_inherited'].')</span>' : ''; |
|
| 1073 | + $tvName = $modx->hasPermission('edit_template') ? '<br/><small class="protectedNode">[*'.$row['name'].'*]</small>' : ''; |
|
| 1074 | 1074 | |
| 1075 | 1075 | $templateVariablesTmp .= ' |
| 1076 | 1076 | <tr> |
| 1077 | - <td><span class="warning">' . $row['caption'] . $tvName . '</span>' . $tvDescription . $tvInherited . '</td> |
|
| 1078 | - <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '') . '">' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '</div></td> |
|
| 1077 | + <td><span class="warning">' . $row['caption'].$tvName.'</span>'.$tvDescription.$tvInherited.'</td> |
|
| 1078 | + <td><div style="position:relative;' . ($row['type'] == 'date' ? '' : '').'">'.renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray).'</div></td> |
|
| 1079 | 1079 | </tr>'; |
| 1080 | 1080 | |
| 1081 | 1081 | if ($group_tvs && $row['category_id'] == 0) { |
@@ -1089,38 +1089,38 @@ discard block |
||
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | if ($templateVariablesGeneral) { |
| 1092 | - echo '<table id="tabTV_0" class="tmplvars"><tbody>' . $templateVariablesGeneral . '</tbody></table>'; |
|
| 1092 | + echo '<table id="tabTV_0" class="tmplvars"><tbody>'.$templateVariablesGeneral.'</tbody></table>'; |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | $templateVariables .= ' |
| 1096 | 1096 | <!-- Template Variables -->' . "\n"; |
| 1097 | 1097 | if (!$group_tvs) { |
| 1098 | 1098 | $templateVariables .= ' |
| 1099 | - <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
|
| 1099 | + <div class="sectionHeader" id="tv_header">' . $_lang['settings_templvars'].'</div> |
|
| 1100 | 1100 | <div class="sectionBody tmplvars"> |
| 1101 | 1101 | <table>'; |
| 1102 | 1102 | } else if ($group_tvs == 2) { |
| 1103 | 1103 | $templateVariables .= ' |
| 1104 | 1104 | <div class="tab-section"> |
| 1105 | - <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'] . '</div> |
|
| 1105 | + <div class="tab-header" id="tv_header">' . $_lang['settings_templvars'].'</div> |
|
| 1106 | 1106 | <div class="tab-pane" id="paneTemplateVariables"> |
| 1107 | 1107 | <script type="text/javascript"> |
| 1108 | - tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
| 1108 | + tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
| 1109 | 1109 | </script>'; |
| 1110 | 1110 | } else if ($group_tvs == 3) { |
| 1111 | 1111 | $templateVariables .= ' |
| 1112 | 1112 | <div id="templateVariables" class="tab-page tmplvars"> |
| 1113 | - <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
|
| 1113 | + <h2 class="tab">' . $_lang['settings_templvars'].'</h2> |
|
| 1114 | 1114 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script>'; |
| 1115 | 1115 | } else if ($group_tvs == 4) { |
| 1116 | 1116 | $templateVariables .= ' |
| 1117 | 1117 | <div id="templateVariables" class="tab-page tmplvars"> |
| 1118 | - <h2 class="tab">' . $_lang['settings_templvars'] . '</h2> |
|
| 1118 | + <h2 class="tab">' . $_lang['settings_templvars'].'</h2> |
|
| 1119 | 1119 | <script type="text/javascript">tpSettings.addTabPage(document.getElementById(\'templateVariables\'));</script> |
| 1120 | 1120 | |
| 1121 | 1121 | <div class="tab-pane" id="paneTemplateVariables"> |
| 1122 | 1122 | <script type="text/javascript"> |
| 1123 | - tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . '); |
|
| 1123 | + tpTemplateVariables = new WebFXTabPane(document.getElementById(\'paneTemplateVariables\'), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false').'); |
|
| 1124 | 1124 | </script>'; |
| 1125 | 1125 | } |
| 1126 | 1126 | $templateVariables .= $templateVariablesOutput; |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | |
| 1213 | 1213 | <?php |
| 1214 | 1214 | |
| 1215 | - if($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1215 | + if ($_SESSION['mgrRole'] == 1 || $modx->manager->action != '27' || $_SESSION['mgrInternalKey'] == $content['createdby'] || $modx->hasPermission('change_resourcetype')) { |
|
| 1216 | 1216 | ?> |
| 1217 | 1217 | <tr> |
| 1218 | 1218 | <td> |
@@ -1235,13 +1235,13 @@ discard block |
||
| 1235 | 1235 | <td> |
| 1236 | 1236 | <select name="contentType" class="inputBox" onchange="documentDirty=true;"> |
| 1237 | 1237 | <?php |
| 1238 | - if(!$content['contentType']) { |
|
| 1238 | + if (!$content['contentType']) { |
|
| 1239 | 1239 | $content['contentType'] = 'text/html'; |
| 1240 | 1240 | } |
| 1241 | 1241 | $custom_contenttype = (isset ($custom_contenttype) ? $custom_contenttype : "text/html,text/plain,text/xml"); |
| 1242 | 1242 | $ct = explode(",", $custom_contenttype); |
| 1243 | - for($i = 0; $i < count($ct); $i++) { |
|
| 1244 | - echo "\t\t\t\t\t" . '<option value="' . $ct[$i] . '"' . ($content['contentType'] == $ct[$i] ? ' selected="selected"' : '') . '>' . $ct[$i] . "</option>\n"; |
|
| 1243 | + for ($i = 0; $i < count($ct); $i++) { |
|
| 1244 | + echo "\t\t\t\t\t".'<option value="'.$ct[$i].'"'.($content['contentType'] == $ct[$i] ? ' selected="selected"' : '').'>'.$ct[$i]."</option>\n"; |
|
| 1245 | 1245 | } |
| 1246 | 1246 | ?> |
| 1247 | 1247 | </select> |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | </tr> |
| 1268 | 1268 | <?php |
| 1269 | 1269 | } else { |
| 1270 | - if($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1270 | + if ($content['type'] != 'reference' && $modx->manager->action != '72') { |
|
| 1271 | 1271 | // non-admin managers creating or editing a document resource |
| 1272 | 1272 | ?> |
| 1273 | 1273 | <input type="hidden" name="contentType" value="<?= (isset($content['contentType']) ? $content['contentType'] : "text/html") ?>" /> |
@@ -1367,15 +1367,15 @@ discard block |
||
| 1367 | 1367 | <?php |
| 1368 | 1368 | /******************************* |
| 1369 | 1369 | * Document Access Permissions */ |
| 1370 | - if($use_udperms == 1) { |
|
| 1370 | + if ($use_udperms == 1) { |
|
| 1371 | 1371 | $groupsarray = array(); |
| 1372 | 1372 | $sql = ''; |
| 1373 | 1373 | |
| 1374 | 1374 | $documentId = ($modx->manager->action == '27' ? $id : (!empty($_REQUEST['pid']) ? $_REQUEST['pid'] : $content['parent'])); |
| 1375 | - if($documentId > 0) { |
|
| 1375 | + if ($documentId > 0) { |
|
| 1376 | 1376 | // Load up, the permissions from the parent (if new document) or existing document |
| 1377 | 1377 | $rs = $modx->db->select('id, document_group', $tbl_document_groups, "document='{$documentId}'"); |
| 1378 | - while($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'] . ',' . $currentgroup['id']; |
|
| 1378 | + while ($currentgroup = $modx->db->getRow($rs)) $groupsarray[] = $currentgroup['document_group'].','.$currentgroup['id']; |
|
| 1379 | 1379 | |
| 1380 | 1380 | // Load up the current permissions and names |
| 1381 | 1381 | $vs = array( |
@@ -1391,7 +1391,7 @@ discard block |
||
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | 1393 | // retain selected doc groups between post |
| 1394 | - if(isset($_POST['docgroups'])) { |
|
| 1394 | + if (isset($_POST['docgroups'])) { |
|
| 1395 | 1395 | $groupsarray = array_merge($groupsarray, $_POST['docgroups']); |
| 1396 | 1396 | } |
| 1397 | 1397 | |
@@ -1410,26 +1410,26 @@ discard block |
||
| 1410 | 1410 | $permissions_no = 0; // count permissions the current mgr user doesn't have |
| 1411 | 1411 | |
| 1412 | 1412 | // Loop through the permissions list |
| 1413 | - while($row = $modx->db->getRow($rs)) { |
|
| 1413 | + while ($row = $modx->db->getRow($rs)) { |
|
| 1414 | 1414 | |
| 1415 | 1415 | // Create an inputValue pair (group ID and group link (if it exists)) |
| 1416 | - $inputValue = $row['id'] . ',' . ($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1417 | - $inputId = 'group-' . $row['id']; |
|
| 1416 | + $inputValue = $row['id'].','.($row['link_id'] ? $row['link_id'] : 'new'); |
|
| 1417 | + $inputId = 'group-'.$row['id']; |
|
| 1418 | 1418 | |
| 1419 | 1419 | $checked = in_array($inputValue, $groupsarray); |
| 1420 | - if($checked) { |
|
| 1420 | + if ($checked) { |
|
| 1421 | 1421 | $notPublic = true; |
| 1422 | 1422 | } // Mark as private access (either web or manager) |
| 1423 | 1423 | |
| 1424 | 1424 | // Skip the access permission if the user doesn't have access... |
| 1425 | - if((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1425 | + if ((!$isManager && $row['private_memgroup'] == '1') || (!$isWeb && $row['private_webgroup'] == '1')) { |
|
| 1426 | 1426 | continue; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | // Setup attributes for this Input box |
| 1430 | 1430 | $inputAttributes['id'] = $inputId; |
| 1431 | 1431 | $inputAttributes['value'] = $inputValue; |
| 1432 | - if($checked) { |
|
| 1432 | + if ($checked) { |
|
| 1433 | 1433 | $inputAttributes['checked'] = 'checked'; |
| 1434 | 1434 | } else { |
| 1435 | 1435 | unset($inputAttributes['checked']); |
@@ -1437,10 +1437,10 @@ discard block |
||
| 1437 | 1437 | |
| 1438 | 1438 | // Create attribute string list |
| 1439 | 1439 | $inputString = array(); |
| 1440 | - foreach($inputAttributes as $k => $v) $inputString[] = $k . '="' . $v . '"'; |
|
| 1440 | + foreach ($inputAttributes as $k => $v) $inputString[] = $k.'="'.$v.'"'; |
|
| 1441 | 1441 | |
| 1442 | 1442 | // Make the <input> HTML |
| 1443 | - $inputHTML = '<input ' . implode(' ', $inputString) . ' />'; |
|
| 1443 | + $inputHTML = '<input '.implode(' ', $inputString).' />'; |
|
| 1444 | 1444 | |
| 1445 | 1445 | // does user have this permission? |
| 1446 | 1446 | $from = "{$tbl_membergroup_access} AS mga, {$tbl_member_groups} AS mg"; |
@@ -1451,23 +1451,23 @@ discard block |
||
| 1451 | 1451 | $where = vsprintf("mga.membergroup=mg.user_group AND mga.documentgroup=%s AND mg.member=%s", $vs); |
| 1452 | 1452 | $rsp = $modx->db->select('COUNT(mg.id)', $from, $where); |
| 1453 | 1453 | $count = $modx->db->getValue($rsp); |
| 1454 | - if($count > 0) { |
|
| 1454 | + if ($count > 0) { |
|
| 1455 | 1455 | ++$permissions_yes; |
| 1456 | 1456 | } else { |
| 1457 | 1457 | ++$permissions_no; |
| 1458 | 1458 | } |
| 1459 | - $permissions[] = "\t\t" . '<li>' . $inputHTML . '<label for="' . $inputId . '">' . $row['name'] . '</label></li>'; |
|
| 1459 | + $permissions[] = "\t\t".'<li>'.$inputHTML.'<label for="'.$inputId.'">'.$row['name'].'</label></li>'; |
|
| 1460 | 1460 | } |
| 1461 | 1461 | // if mgr user doesn't have access to any of the displayable permissions, forget about them and make doc public |
| 1462 | - if($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1462 | + if ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0)) { |
|
| 1463 | 1463 | $permissions = array(); |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | // See if the Access Permissions section is worth displaying... |
| 1467 | - if(!empty($permissions)) { |
|
| 1467 | + if (!empty($permissions)) { |
|
| 1468 | 1468 | // Add the "All Document Groups" item if we have rights in both contexts |
| 1469 | - if($isManager && $isWeb) { |
|
| 1470 | - 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>'); |
|
| 1469 | + if ($isManager && $isWeb) { |
|
| 1470 | + 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>'); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | // Output the permissions list... |
| 1473 | 1473 | ?> |
@@ -1500,12 +1500,12 @@ discard block |
||
| 1500 | 1500 | </script> |
| 1501 | 1501 | <p><?= $_lang['access_permissions_docs_message'] ?></p> |
| 1502 | 1502 | <ul> |
| 1503 | - <?= implode("\n", $permissions) . "\n" ?> |
|
| 1503 | + <?= implode("\n", $permissions)."\n" ?> |
|
| 1504 | 1504 | </ul> |
| 1505 | 1505 | </div><!--div class="tab-page" id="tabAccess"--> |
| 1506 | 1506 | <?php |
| 1507 | 1507 | } // !empty($permissions) |
| 1508 | - elseif($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1508 | + elseif ($_SESSION['mgrRole'] != 1 && ($permissions_yes == 0 && $permissions_no > 0) && ($_SESSION['mgrPermissions']['access_permissions'] == 1 || $_SESSION['mgrPermissions']['web_access_permissions'] == 1)) { |
|
| 1509 | 1509 | ?> |
| 1510 | 1510 | <p><?= $_lang["access_permissions_docs_collision"] ?></p> |
| 1511 | 1511 | <?php |
@@ -1525,7 +1525,7 @@ discard block |
||
| 1525 | 1525 | 'template' => $content['template'] |
| 1526 | 1526 | )); |
| 1527 | 1527 | |
| 1528 | - if(is_array($evtOut)) { |
|
| 1528 | + if (is_array($evtOut)) { |
|
| 1529 | 1529 | echo implode('', $evtOut); |
| 1530 | 1530 | } |
| 1531 | 1531 | ?> |
@@ -1538,16 +1538,16 @@ discard block |
||
| 1538 | 1538 | storeCurTemplate(); |
| 1539 | 1539 | </script> |
| 1540 | 1540 | <?php |
| 1541 | -if(($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
|
| 1542 | - if(is_array($richtexteditorIds)) { |
|
| 1543 | - foreach($richtexteditorIds as $editor => $elements) { |
|
| 1541 | +if (($content['richtext'] == 1 || $modx->manager->action == '4' || $modx->manager->action == '72') && $use_editor == 1) { |
|
| 1542 | + if (is_array($richtexteditorIds)) { |
|
| 1543 | + foreach ($richtexteditorIds as $editor => $elements) { |
|
| 1544 | 1544 | // invoke OnRichTextEditorInit event |
| 1545 | 1545 | $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( |
| 1546 | 1546 | 'editor' => $editor, |
| 1547 | 1547 | 'elements' => $elements, |
| 1548 | 1548 | 'options' => $richtexteditorOptions[$editor] |
| 1549 | 1549 | )); |
| 1550 | - if(is_array($evtOut)) { |
|
| 1550 | + if (is_array($evtOut)) { |
|
| 1551 | 1551 | echo implode('', $evtOut); |
| 1552 | 1552 | } |
| 1553 | 1553 | } |
@@ -1557,37 +1557,37 @@ discard block |
||
| 1557 | 1557 | /** |
| 1558 | 1558 | * @return string |
| 1559 | 1559 | */ |
| 1560 | -function getDefaultTemplate() { |
|
| 1560 | +function getDefaultTemplate(){ |
|
| 1561 | 1561 | $modx = evolutionCMS(); |
| 1562 | 1562 | |
| 1563 | 1563 | $default_template = ''; |
| 1564 | - switch($modx->config['auto_template_logic']) { |
|
| 1564 | + switch ($modx->config['auto_template_logic']) { |
|
| 1565 | 1565 | case 'sibling': |
| 1566 | - if(!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1566 | + if (!isset($_GET['pid']) || empty($_GET['pid'])) { |
|
| 1567 | 1567 | $site_start = $modx->config['site_start']; |
| 1568 | 1568 | $where = "sc.isfolder=0 AND sc.id!='{$site_start}'"; |
| 1569 | 1569 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', $where, 'menuindex', 'ASC', 1); |
| 1570 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1570 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1571 | 1571 | $default_template = $sibl[0]['template']; |
| 1572 | 1572 | } |
| 1573 | 1573 | } else { |
| 1574 | 1574 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
| 1575 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1575 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1576 | 1576 | $default_template = $sibl[0]['template']; |
| 1577 | 1577 | } else { |
| 1578 | 1578 | $sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template', 'isfolder=0', 'menuindex', 'ASC', 1); |
| 1579 | - if(isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1579 | + if (isset($sibl[0]['template']) && $sibl[0]['template'] !== '') { |
|
| 1580 | 1580 | $default_template = $sibl[0]['template']; |
| 1581 | 1581 | } |
| 1582 | 1582 | } |
| 1583 | 1583 | } |
| 1584 | - if(isset($default_template)) { |
|
| 1584 | + if (isset($default_template)) { |
|
| 1585 | 1585 | break; |
| 1586 | 1586 | } // If $default_template could not be determined, fall back / through to "parent"-mode |
| 1587 | 1587 | case 'parent': |
| 1588 | - if(isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1588 | + if (isset($_REQUEST['pid']) && !empty($_REQUEST['pid'])) { |
|
| 1589 | 1589 | $parent = $modx->getPageInfo($_REQUEST['pid'], 0, 'template'); |
| 1590 | - if(isset($parent['template'])) { |
|
| 1590 | + if (isset($parent['template'])) { |
|
| 1591 | 1591 | $default_template = $parent['template']; |
| 1592 | 1592 | } |
| 1593 | 1593 | } |
@@ -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 | - $modx = evolutionCMS(); global $_lang; |
|
| 21 | - $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 22 | - return $modx->parseText($tpl, $ph); |
|
| 20 | + $modx = evolutionCMS(); global $_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 | - $modx = evolutionCMS(); global $_lang, $tpl; |
|
| 30 | + $modx = evolutionCMS(); global $_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 | - $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl; |
|
| 43 | + $modx = evolutionCMS(); global $_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 | - $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir; |
|
| 96 | + $modx = evolutionCMS(); global $_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 | - $modx = evolutionCMS(); global $modx_textdir, $_style, $_lang; |
|
| 153 | + $modx = evolutionCMS(); global $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,14 +1,14 @@ 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 | |
| 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 | /** |
@@ -16,7 +16,7 @@ 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 | $modx = evolutionCMS(); global $_lang; |
| 21 | 21 | $tpl = $modx->parseText($tpl, $_lang, '[%', '%]'); |
| 22 | 22 | return $modx->parseText($tpl, $ph); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param string|int $cssId |
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | -function renderViewSwitchButtons($cssId) {
|
|
| 29 | +function renderViewSwitchButtons($cssId){
|
|
| 30 | 30 | $modx = evolutionCMS(); global $_lang, $tpl; |
| 31 | 31 | |
| 32 | 32 | return parsePh($tpl['viewForm'], array( |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | * @param mgrResources $resources |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | -function createResourceList($resourceTable, $resources) {
|
|
| 42 | +function createResourceList($resourceTable, $resources){
|
|
| 43 | 43 | $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir, $tpl; |
| 44 | 44 | |
| 45 | 45 | $items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false; |
| 46 | 46 | |
| 47 | - if( ! is_array($items) || empty($items)) {
|
|
| 47 | + if (!is_array($items) || empty($items)) {
|
|
| 48 | 48 | return $_lang['no_results']; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Prepare elements- and categories-list |
| 52 | 52 | $elements = array(); |
| 53 | 53 | $categories = array(); |
| 54 | - foreach($items as $row) {
|
|
| 54 | + foreach ($items as $row) {
|
|
| 55 | 55 | $catid = $row['catid'] ? $row['catid'] : 0; |
| 56 | 56 | $categories[$catid] = array('name' => stripslashes($row['category']));
|
| 57 | 57 | $elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources); |
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | // Now render categories / panel-collapse |
| 61 | 61 | $panelGroup = ''; |
| 62 | - foreach($elements as $catid => $elList) {
|
|
| 62 | + foreach ($elements as $catid => $elList) {
|
|
| 63 | 63 | // Add panel-heading / category-collapse to output |
| 64 | 64 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
| 65 | 65 | 'tab' => $resourceTable, |
| 66 | 66 | 'category' => $categories[$catid]['name'], |
| 67 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 67 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
|
|
| 68 | 68 | 'catid' => $catid, |
| 69 | 69 | )); |
| 70 | 70 | |
| 71 | 71 | // Prepare content for panel-collapse |
| 72 | 72 | $panelCollapse = ''; |
| 73 | - foreach($elList as $el) {
|
|
| 73 | + foreach ($elList as $el) {
|
|
| 74 | 74 | $panelCollapse .= parsePh($tpl['elementsRow'], $el); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -92,30 +92,30 @@ discard block |
||
| 92 | 92 | * @param mgrResources $resources |
| 93 | 93 | * @return string |
| 94 | 94 | */ |
| 95 | -function createCombinedView($resources) {
|
|
| 95 | +function createCombinedView($resources){
|
|
| 96 | 96 | $modx = evolutionCMS(); global $_lang, $_style, $modx_textdir; |
| 97 | 97 | |
| 98 | 98 | $itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false; |
| 99 | 99 | $types = isset($resources->types) ? $resources->types : false; |
| 100 | 100 | $categories = isset($resources->categories) ? $resources->categories : false; |
| 101 | 101 | |
| 102 | - if(!$itemsPerCategory) {
|
|
| 102 | + if (!$itemsPerCategory) {
|
|
| 103 | 103 | return $_lang['no_results']; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 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'), |
|
| 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 | 111 | ); |
| 112 | 112 | |
| 113 | 113 | // Easily loop through $itemsPerCategory-Array |
| 114 | 114 | $panelGroup = ''; |
| 115 | - foreach($categories as $catid => $category) {
|
|
| 115 | + foreach ($categories as $catid => $category) {
|
|
| 116 | 116 | // Prepare collapse content / elements-list |
| 117 | 117 | $panelCollapse = ''; |
| 118 | - foreach($itemsPerCategory[$catid] as $el) {
|
|
| 118 | + foreach ($itemsPerCategory[$catid] as $el) {
|
|
| 119 | 119 | $resourceTable = $el['type']; |
| 120 | 120 | $ph = prepareElementRowPh($el, $resourceTable, $resources); |
| 121 | 121 | $panelCollapse .= parsePh($tpl['elementsRow'], $ph); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $panelGroup .= parsePh($tpl['panelHeading'], array( |
| 126 | 126 | 'tab' => 'categories_list', |
| 127 | 127 | 'category' => $categories[$catid], |
| 128 | - 'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
|
|
| 128 | + 'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
|
|
| 129 | 129 | 'catid' => $catid, |
| 130 | 130 | )); |
| 131 | 131 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | * @param mgrResources $resources |
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | -function prepareElementRowPh($row, $resourceTable, $resources) {
|
|
| 152 | +function prepareElementRowPh($row, $resourceTable, $resources){
|
|
| 153 | 153 | $modx = evolutionCMS(); global $modx_textdir, $_style, $_lang; |
| 154 | 154 | |
| 155 | 155 | $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; |
| 156 | 156 | |
| 157 | 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; |
@@ -193,65 +193,65 @@ discard block |
||
| 193 | 193 | // Prepare displaying user-locks |
| 194 | 194 | $lockedByUser = ''; |
| 195 | 195 | $rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true); |
| 196 | - if($rowLock && $modx->hasPermission('display_locks')) {
|
|
| 197 | - if($rowLock['sid'] == $modx->sid) {
|
|
| 196 | + if ($rowLock && $modx->hasPermission('display_locks')) {
|
|
| 197 | + if ($rowLock['sid'] == $modx->sid) {
|
|
| 198 | 198 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
| 199 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 199 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
| 200 | 200 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 201 | 201 | )); |
| 202 | - $lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span> '; |
|
| 202 | + $lockedByUser = '<span title="'.$title.'" class="editResource" style="cursor:context-menu;">'.$_style['tree_preview_resource'].'</span> '; |
|
| 203 | 203 | } else {
|
| 204 | 204 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
| 205 | - 'element_type' => $_lang["lock_element_type_" . $lockElementType], |
|
| 205 | + 'element_type' => $_lang["lock_element_type_".$lockElementType], |
|
| 206 | 206 | 'username' => $rowLock['username'], |
| 207 | 207 | 'lasthit_df' => $rowLock['lasthit_df'] |
| 208 | 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>';
|
|
| 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 | 211 | } else {
|
| 212 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>'; |
|
| 212 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource" style="cursor:context-menu;"><i class="'.$_style['icons_secured'].'"></i></span>'; |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - if($lockedByUser) {
|
|
| 217 | - $lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>'; |
|
| 216 | + if ($lockedByUser) {
|
|
| 217 | + $lockedByUser = '<div class="lockCell">'.$lockedByUser.'</div>'; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Caption |
| 221 | - if($resourceTable == 'site_tmplvars') {
|
|
| 222 | - $caption = !empty($row['description']) ? ' ' . $row['caption'] . ' <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
|
|
| 221 | + if ($resourceTable == 'site_tmplvars') {
|
|
| 222 | + $caption = !empty($row['description']) ? ' '.$row['caption'].' <small>('.$row['description'].')</small>' : ' '.$row['caption'];
|
|
| 223 | 223 | } else {
|
| 224 | - $caption = !empty($row['description']) ? ' ' . $row['description'] : ''; |
|
| 224 | + $caption = !empty($row['description']) ? ' '.$row['description'] : ''; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Special marks |
| 228 | 228 | $tplInfo = array(); |
| 229 | - if($row['locked']) {
|
|
| 229 | + if ($row['locked']) {
|
|
| 230 | 230 | $tplInfo[] = $_lang['locked']; |
| 231 | 231 | } |
| 232 | - if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
|
|
| 232 | + if ($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
|
|
| 233 | 233 | $tplInfo[] = $_lang['defaulttemplate_title']; |
| 234 | 234 | } |
| 235 | - $marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
|
|
| 235 | + $marks = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : '';
|
|
| 236 | 236 | |
| 237 | 237 | /* row buttons */ |
| 238 | 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>'; |
|
| 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 | 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>'; |
|
| 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 | 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>'; |
|
| 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 | 247 | } |
| 248 | - $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : ''; |
|
| 248 | + $buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">'.$buttons.'</ul></div>' : ''; |
|
| 249 | 249 | |
| 250 | 250 | $catid = $row['catid'] ? $row['catid'] : 0; |
| 251 | 251 | |
| 252 | 252 | // Placeholders for elements-row |
| 253 | 253 | return array( |
| 254 | - 'class' => $class ? ' class="' . $class . '"' : '', |
|
| 254 | + 'class' => $class ? ' class="'.$class.'"' : '', |
|
| 255 | 255 | 'lockedByUser' => $lockedByUser, |
| 256 | 256 | 'name' => $row['name'], |
| 257 | 257 | 'caption' => $caption, |
@@ -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 | $modx = evolutionCMS(); global $_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 | $modx = evolutionCMS(); global $_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 | $modx = evolutionCMS(); global $_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 | $modx = evolutionCMS(); global $_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 | $modx = evolutionCMS(); global $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 | - $modx = evolutionCMS(); |
|
| 88 | + $modx = evolutionCMS(); |
|
| 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 | - $modx = evolutionCMS(); global $_lang; |
|
| 102 | + $modx = evolutionCMS(); global $_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 | } |
@@ -1,9 +1,9 @@ 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 | |
| 6 | -class mgrResources { |
|
| 6 | +class mgrResources{ |
|
| 7 | 7 | /** |
| 8 | 8 | * @var array |
| 9 | 9 | */ |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * mgrResources constructor. |
| 26 | 26 | */ |
| 27 | - public function __construct() { |
|
| 27 | + public function __construct(){ |
|
| 28 | 28 | $this->setTypes(); |
| 29 | 29 | $this->queryItemsFromDB(); |
| 30 | 30 | $this->prepareCategoryArrays(); |
@@ -33,47 +33,47 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | - public function setTypes() { |
|
| 36 | + public function setTypes(){ |
|
| 37 | 37 | global $_lang; |
| 38 | - $this->types['site_templates'] = array( |
|
| 38 | + $this->types['site_templates'] = array( |
|
| 39 | 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'), |
|
| 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 | 42 | 'name'=>'templatename' |
| 43 | 43 | ); |
| 44 | - $this->types['site_tmplvars'] = array( |
|
| 44 | + $this->types['site_tmplvars'] = array( |
|
| 45 | 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'), |
|
| 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 | 48 | ); |
| 49 | 49 | $this->types['site_htmlsnippets'] = array( |
| 50 | 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'), |
|
| 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 | 53 | ); |
| 54 | - $this->types['site_snippets'] = array( |
|
| 54 | + $this->types['site_snippets'] = array( |
|
| 55 | 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'), |
|
| 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 | 58 | ); |
| 59 | - $this->types['site_plugins'] = array( |
|
| 59 | + $this->types['site_plugins'] = array( |
|
| 60 | 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'), |
|
| 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 | 63 | ); |
| 64 | - $this->types['site_modules'] = array( |
|
| 64 | + $this->types['site_modules'] = array( |
|
| 65 | 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'), |
|
| 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 | 68 | ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | - public function queryItemsFromDB() { |
|
| 75 | - foreach($this->types as $resourceTable=>$type) { |
|
| 76 | - if($this->hasAnyPermissions($type['permissions'])) { |
|
| 74 | + public function queryItemsFromDB(){ |
|
| 75 | + foreach ($this->types as $resourceTable=>$type) { |
|
| 76 | + if ($this->hasAnyPermissions($type['permissions'])) { |
|
| 77 | 77 | $nameField = isset($type['name']) ? $type['name'] : 'name'; |
| 78 | 78 | $this->items[$resourceTable] = $this->queryResources($resourceTable, $nameField); |
| 79 | 79 | } |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | * @param array $permissions |
| 85 | 85 | * @return bool |
| 86 | 86 | */ |
| 87 | - public function hasAnyPermissions($permissions) { |
|
| 87 | + public function hasAnyPermissions($permissions){ |
|
| 88 | 88 | $modx = evolutionCMS(); |
| 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 | 93 | return false; |
| 94 | 94 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param string $nameField |
| 99 | 99 | * @return array|bool |
| 100 | 100 | */ |
| 101 | - public function queryResources($resourceTable, $nameField = 'name') { |
|
| 101 | + public function queryResources($resourceTable, $nameField = 'name'){ |
|
| 102 | 102 | $modx = evolutionCMS(); global $_lang; |
| 103 | 103 | |
| 104 | 104 | $allowed = array( |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | 'site_plugins', |
| 108 | 108 | 'site_modules' |
| 109 | 109 | ); |
| 110 | - $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable . '.disabled, ' : ''; |
|
| 110 | + $pluginsql = !empty($resourceTable) && in_array($resourceTable, $allowed) ? $resourceTable.'.disabled, ' : ''; |
|
| 111 | 111 | |
| 112 | 112 | $tvsql = ''; |
| 113 | 113 | $tvjoin = ''; |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $rs = $modx->db->select( |
| 124 | 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 | - LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
| 125 | + $modx->getFullTableName($resourceTable)." AS {$resourceTable} |
|
| 126 | + LEFT JOIN ".$modx->getFullTableName('categories')." AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", |
|
| 127 | 127 | "", |
| 128 | 128 | "category,name" |
| 129 | 129 | ); |
| 130 | 130 | $limit = $modx->db->getRecordCount($rs); |
| 131 | 131 | |
| 132 | - if($limit < 1) return false; |
|
| 132 | + if ($limit < 1) return false; |
|
| 133 | 133 | |
| 134 | 134 | $result = array(); |
| 135 | 135 | while ($row = $modx->db->getRow($rs)) { |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * @return void |
| 143 | 143 | */ |
| 144 | - public function prepareCategoryArrays() { |
|
| 145 | - foreach($this->items as $type=>$items) { |
|
| 146 | - foreach((array)$items as $item) { |
|
| 144 | + public function prepareCategoryArrays(){ |
|
| 145 | + foreach ($this->items as $type=>$items) { |
|
| 146 | + foreach ((array) $items as $item) { |
|
| 147 | 147 | $catid = $item['catid'] ? $item['catid'] : 0; |
| 148 | 148 | $this->categories[$catid] = $item['category']; |
| 149 | 149 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | natcasesort($this->categories); |
| 157 | 157 | |
| 158 | 158 | // Now sort by name |
| 159 | - foreach($this->itemsPerCategory as $catid=>$items) { |
|
| 160 | - usort($this->itemsPerCategory[$catid], function ($a, $b) { |
|
| 159 | + foreach ($this->itemsPerCategory as $catid=>$items) { |
|
| 160 | + usort($this->itemsPerCategory[$catid], function($a, $b){ |
|
| 161 | 161 | return strcasecmp($a['name'], $b['name']); |
| 162 | 162 | }); |
| 163 | 163 | } |
@@ -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 | $modx = evolutionCMS(); |
| 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 | $modx = evolutionCMS(); global $_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 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | $modx->getSettings(); |
| 6 | 6 | $modx->invokeEvent('OnWebPageInit'); |
| 7 | 7 | |
| 8 | -$vword = new VeriWord(148,60); |
|
| 8 | +$vword = new VeriWord(148, 60); |
|
| 9 | 9 | $vword->output_image(); |
| 10 | 10 | $vword->destroy_image(); |
| 11 | 11 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord{ |
|
| 45 | 45 | |
| 46 | 46 | /* path to font directory*/ |
| 47 | 47 | public $dir_font = "ttf/"; |
@@ -52,44 +52,44 @@ discard block |
||
| 52 | 52 | public $im_height = 0; |
| 53 | 53 | public $im; |
| 54 | 54 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 55 | + public function __construct($w = 200, $h = 80){ |
|
| 56 | 56 | /* create session to set word for verification */ |
| 57 | 57 | $this->set_veriword(); |
| 58 | - $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
|
| 58 | + $this->dir_font = dirname(__FILE__).'/'.$this->dir_font; |
|
| 59 | 59 | $this->im_width = $w; |
| 60 | 60 | $this->im_height = $h; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function set_veriword() { |
|
| 63 | + public function set_veriword(){ |
|
| 64 | 64 | /* create session variable for verification, |
| 65 | 65 | you may change the session variable name */ |
| 66 | 66 | $this->word = $this->pick_word(); |
| 67 | 67 | $_SESSION['veriword'] = $this->word; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function output_image() { |
|
| 70 | + public function output_image(){ |
|
| 71 | 71 | /* output the image as jpeg */ |
| 72 | 72 | $this->draw_image(); |
| 73 | 73 | header("Content-type: image/jpeg"); |
| 74 | 74 | imagejpeg($this->im); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function pick_word() { |
|
| 77 | + public function pick_word(){ |
|
| 78 | 78 | $modx = evolutionCMS(); |
| 79 | 79 | // set default words |
| 80 | - $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 80 | + $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 81 | 81 | $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words; |
| 82 | 82 | $arr_words = array_filter(array_map('trim', explode(',', $words))); |
| 83 | 83 | |
| 84 | 84 | /* pick one randomly for text verification */ |
| 85 | - return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
|
| 85 | + return (string) $arr_words[array_rand($arr_words)].rand(10, 999); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function draw_text() { |
|
| 88 | + public function draw_text(){ |
|
| 89 | 89 | $dir = dir($this->dir_font); |
| 90 | 90 | $fontstmp = array(); |
| 91 | 91 | while (false !== ($file = $dir->read())) { |
| 92 | - if(substr($file, -4) == '.ttf') { |
|
| 92 | + if (substr($file, -4) == '.ttf') { |
|
| 93 | 93 | $fontstmp[] = $this->dir_font.$file; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -97,35 +97,35 @@ discard block |
||
| 97 | 97 | $text_font = (string) $fontstmp[array_rand($fontstmp)]; |
| 98 | 98 | |
| 99 | 99 | /* angle for text inclination */ |
| 100 | - $text_angle = rand(-9,9); |
|
| 100 | + $text_angle = rand(-9, 9); |
|
| 101 | 101 | /* initial text size */ |
| 102 | 102 | $text_size = 30; |
| 103 | 103 | /* calculate text width and height */ |
| 104 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 105 | - $text_width = $box[2]-$box[0]; //text width |
|
| 106 | - $text_height= $box[5]-$box[3]; //text height |
|
| 104 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 105 | + $text_width = $box[2] - $box[0]; //text width |
|
| 106 | + $text_height = $box[5] - $box[3]; //text height |
|
| 107 | 107 | |
| 108 | 108 | /* adjust text size */ |
| 109 | - $text_size = round((20 * $this->im_width)/$text_width); |
|
| 109 | + $text_size = round((20 * $this->im_width) / $text_width); |
|
| 110 | 110 | |
| 111 | 111 | /* recalculate text width and height */ |
| 112 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 113 | - $text_width = $box[2]-$box[0]; //text width |
|
| 114 | - $text_height= $box[5]-$box[3]; //text height |
|
| 112 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 113 | + $text_width = $box[2] - $box[0]; //text width |
|
| 114 | + $text_height = $box[5] - $box[3]; //text height |
|
| 115 | 115 | |
| 116 | 116 | /* calculate center position of text */ |
| 117 | - $text_x = ($this->im_width - $text_width)/2; |
|
| 118 | - $text_y = ($this->im_height - $text_height)/2; |
|
| 117 | + $text_x = ($this->im_width - $text_width) / 2; |
|
| 118 | + $text_y = ($this->im_height - $text_height) / 2; |
|
| 119 | 119 | |
| 120 | 120 | /* create canvas for text drawing */ |
| 121 | - $im_text = imagecreate ($this->im_width, $this->im_height); |
|
| 122 | - $bg_color = imagecolorallocate ($im_text, 255, 255, 255); |
|
| 121 | + $im_text = imagecreate($this->im_width, $this->im_height); |
|
| 122 | + $bg_color = imagecolorallocate($im_text, 255, 255, 255); |
|
| 123 | 123 | |
| 124 | 124 | /* pick color for text */ |
| 125 | - $text_color = imagecolorallocate ($im_text, 0, 51, 153); |
|
| 125 | + $text_color = imagecolorallocate($im_text, 0, 51, 153); |
|
| 126 | 126 | |
| 127 | 127 | /* draw text into canvas */ |
| 128 | - imagettftext ( $im_text, |
|
| 128 | + imagettftext($im_text, |
|
| 129 | 129 | $text_size, |
| 130 | 130 | $text_angle, |
| 131 | 131 | $text_x, |
@@ -140,19 +140,19 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - public function draw_image() { |
|
| 143 | + public function draw_image(){ |
|
| 144 | 144 | |
| 145 | 145 | /* pick one background image randomly from image directory */ |
| 146 | - $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
|
| 146 | + $img_file = $this->dir_noise."noise".rand(1, 4).".jpg"; |
|
| 147 | 147 | |
| 148 | 148 | /* create "noise" background image from your image stock*/ |
| 149 | - $noise_img = @imagecreatefromjpeg ($img_file); |
|
| 149 | + $noise_img = @imagecreatefromjpeg($img_file); |
|
| 150 | 150 | $noise_width = imagesx($noise_img); |
| 151 | 151 | $noise_height = imagesy($noise_img); |
| 152 | 152 | |
| 153 | 153 | /* resize the background image to fit the size of image output */ |
| 154 | - $this->im = imagecreatetruecolor($this->im_width,$this->im_height); |
|
| 155 | - imagecopyresampled ($this->im, |
|
| 154 | + $this->im = imagecreatetruecolor($this->im_width, $this->im_height); |
|
| 155 | + imagecopyresampled($this->im, |
|
| 156 | 156 | $noise_img, |
| 157 | 157 | 0, 0, 0, 0, |
| 158 | 158 | $this->im_width, |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | $noise_height); |
| 162 | 162 | |
| 163 | 163 | /* put text image into background image */ |
| 164 | - imagecopymerge ( $this->im, |
|
| 164 | + imagecopymerge($this->im, |
|
| 165 | 165 | $this->draw_text(), |
| 166 | 166 | 0, 0, 0, 0, |
| 167 | 167 | $this->im_width, |
| 168 | 168 | $this->im_height, |
| 169 | - 70 ); |
|
| 169 | + 70); |
|
| 170 | 170 | |
| 171 | 171 | return $this->im; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function destroy_image() { |
|
| 174 | + public function destroy_image(){ |
|
| 175 | 175 | |
| 176 | 176 | imagedestroy($this->im); |
| 177 | 177 | |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord |
|
| 45 | +{ |
|
| 45 | 46 | |
| 46 | 47 | /* path to font directory*/ |
| 47 | 48 | public $dir_font = "ttf/"; |
@@ -52,7 +53,8 @@ discard block |
||
| 52 | 53 | public $im_height = 0; |
| 53 | 54 | public $im; |
| 54 | 55 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 56 | + public function __construct($w=200, $h=80) |
|
| 57 | + { |
|
| 56 | 58 | /* create session to set word for verification */ |
| 57 | 59 | $this->set_veriword(); |
| 58 | 60 | $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
@@ -60,21 +62,24 @@ discard block |
||
| 60 | 62 | $this->im_height = $h; |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | - public function set_veriword() { |
|
| 65 | + public function set_veriword() |
|
| 66 | + { |
|
| 64 | 67 | /* create session variable for verification, |
| 65 | 68 | you may change the session variable name */ |
| 66 | 69 | $this->word = $this->pick_word(); |
| 67 | 70 | $_SESSION['veriword'] = $this->word; |
| 68 | 71 | } |
| 69 | 72 | |
| 70 | - public function output_image() { |
|
| 73 | + public function output_image() |
|
| 74 | + { |
|
| 71 | 75 | /* output the image as jpeg */ |
| 72 | 76 | $this->draw_image(); |
| 73 | 77 | header("Content-type: image/jpeg"); |
| 74 | 78 | imagejpeg($this->im); |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | - public function pick_word() { |
|
| 81 | + public function pick_word() |
|
| 82 | + { |
|
| 78 | 83 | $modx = evolutionCMS(); |
| 79 | 84 | // set default words |
| 80 | 85 | $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
@@ -85,7 +90,8 @@ discard block |
||
| 85 | 90 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
| 86 | 91 | } |
| 87 | 92 | |
| 88 | - public function draw_text() { |
|
| 93 | + public function draw_text() |
|
| 94 | + { |
|
| 89 | 95 | $dir = dir($this->dir_font); |
| 90 | 96 | $fontstmp = array(); |
| 91 | 97 | while (false !== ($file = $dir->read())) { |
@@ -140,7 +146,8 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | |
| 142 | 148 | |
| 143 | - public function draw_image() { |
|
| 149 | + public function draw_image() |
|
| 150 | + { |
|
| 144 | 151 | |
| 145 | 152 | /* pick one background image randomly from image directory */ |
| 146 | 153 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -171,7 +178,8 @@ discard block |
||
| 171 | 178 | return $this->im; |
| 172 | 179 | } |
| 173 | 180 | |
| 174 | - public function destroy_image() { |
|
| 181 | + public function destroy_image() |
|
| 182 | + { |
|
| 175 | 183 | |
| 176 | 184 | imagedestroy($this->im); |
| 177 | 185 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function setTableWidth($value) |
| 132 | 132 | { |
| 133 | - $this->tableWidth = (int)$value; |
|
| 133 | + $this->tableWidth = (int) $value; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | { |
| 318 | 318 | $currentWidth = ''; |
| 319 | 319 | if (is_array($this->columnWidths)) { |
| 320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
| 320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $currentClass = $this->rowAlternateClass; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return ' class="' . $currentClass . '"'; |
|
| 349 | + return ' class="'.$currentClass.'"'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $cellAction = ''; |
| 362 | 362 | if ($this->cellAction) { |
| 363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
| 363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | $cell = $value; |
| 379 | 379 | if ($this->linkAction) { |
| 380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
| 380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $end = '?'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - return $link . $end; |
|
| 409 | + return $link.$end; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (is_array($fieldsArray)) { |
| 427 | 427 | $i = 0; |
| 428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
| 429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
| 429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
| 430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
| 431 | 431 | if (is_array($this->selectedValues)) { |
| 432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | $colPosition = 0; |
| 438 | 438 | foreach ($fieldValue as $key => $value) { |
| 439 | 439 | if (!in_array($key, $this->excludeFields)) { |
| 440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
| 440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
| 441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
| 442 | 442 | $table .= "</td>\n"; |
| 443 | 443 | if ($i == 0) { |
| 444 | 444 | if (empty ($header) && $this->formElementType) { |
| 445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
| 445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
| 446 | 446 | } |
| 447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
| 448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
| 448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
| 449 | 449 | } |
| 450 | 450 | $colPosition++; |
| 451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
| 453 | 453 | $i++; |
| 454 | 454 | $table .= "\t</tr>\n"; |
| 455 | 455 | } |
| 456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
| 456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
| 457 | 457 | if ($this->formElementType) { |
| 458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
| 458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
| 459 | 459 | } |
| 460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
| 461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
| 471 | 471 | */ |
| 472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
| 472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
| 473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
| 474 | 474 | |
| 475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | <script language="javascript"> |
| 479 | 479 | toggled = 0; |
| 480 | 480 | function clickAll() { |
| 481 | - myform = document.getElementById("' . $this->formName . '"); |
|
| 481 | + myform = document.getElementById("' . $this->formName.'"); |
|
| 482 | 482 | for(i=0;i<myform.length;i++) { |
| 483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
| 484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | if ($this->formElementType) { |
| 492 | 492 | if ($this->extra) { |
| 493 | - $table .= "\n" . $this->extra . "\n"; |
|
| 493 | + $table .= "\n".$this->extra."\n"; |
|
| 494 | 494 | } |
| 495 | - $table .= "\n" . '</form>' . "\n"; |
|
| 495 | + $table .= "\n".'</form>'."\n"; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
| 516 | 516 | $nav = ''; |
| 517 | 517 | if ($numPages > 1) { |
| 518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
| 518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
| 519 | 519 | if ($currentPage > 6) { |
| 520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
| 521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - $this->pageNav = ' ' . $nav; |
|
| 543 | + $this->pageNav = ' '.$nav; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
| 557 | 557 | { |
| 558 | 558 | $modx = evolutionCMS(); |
| 559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
| 560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
| 559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
| 560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
| 561 | 561 | if (!empty($qs)) { |
| 562 | 562 | $qs = "?$qs"; |
| 563 | 563 | } |
| 564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
| 565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
| 566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
| 565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
| 566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
| 567 | 567 | |
| 568 | 568 | return $nav; |
| 569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $field = ''; |
| 582 | 582 | if ($this->formElementType) { |
| 583 | 583 | $checked = $isChecked ? "checked " : ""; |
| 584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
| 584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | public function handlePaging() |
| 596 | 596 | { |
| 597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
| 598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
| 598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
| 599 | 599 | |
| 600 | 600 | return $limitClause; |
| 601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | public function handleSorting($natural_order = false) |
| 611 | 611 | { |
| 612 | 612 | $orderByClause = ''; |
| 613 | - if ((bool)$natural_order === false) { |
|
| 613 | + if ((bool) $natural_order === false) { |
|
| 614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
| 615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
| 616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
| 616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
| 645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | } |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function ProcessFile($file) { |
| 133 | 133 | // get the file |
| 134 | - $buffer = @file_get_contents($file); |
|
| 135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 134 | + $buffer = @file_get_contents($file); |
|
| 135 | + if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 136 | 136 | return $buffer; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | function parseTvValues($param, $tvsArray) |
| 169 | 169 | { |
| 170 | 170 | $modx = evolutionCMS(); |
| 171 | - $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | - if (strpos($param, '[*') !== false) { |
|
| 173 | - $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | - foreach ($matches[0] as $i=>$match) { |
|
| 175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | - $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | - $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | - } else { |
|
| 180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | - } |
|
| 182 | - $param = str_replace($match, $value, $param); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - return $param; |
|
| 171 | + $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | + if (strpos($param, '[*') !== false) { |
|
| 173 | + $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | + foreach ($matches[0] as $i=>$match) { |
|
| 175 | + if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | + if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | + $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | + $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | + } else { |
|
| 180 | + $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | + } |
|
| 182 | + $param = str_replace($match, $value, $param); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + return $param; |
|
| 187 | 187 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * Created by Raymond Irving Feb, 2005 |
| 5 | 5 | */ |
| 6 | 6 | global $BINDINGS; // Array of supported bindings. must be upper case |
| 7 | -$BINDINGS = array ( |
|
| 7 | +$BINDINGS = array( |
|
| 8 | 8 | 'FILE', |
| 9 | 9 | 'CHUNK', |
| 10 | 10 | 'DOCUMENT', |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | * @param array $tvsArray |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
| 25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){ |
|
| 26 | 26 | $modx = evolutionCMS(); |
| 27 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 27 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 28 | 28 | $nvalue = trim($value); |
| 29 | 29 | if (substr($nvalue, 0, 1) != '@') |
| 30 | 30 | return $value; |
| 31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 31 | + elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') { |
|
| 32 | 32 | return '@Bindings is disabled.'; |
| 33 | 33 | } |
| 34 | 34 | else { |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | break; |
| 55 | 55 | |
| 56 | 56 | case "SELECT" : // selects a record from the cms database |
| 57 | - $rt = array (); |
|
| 58 | - $replacementVars = array ( |
|
| 57 | + $rt = array(); |
|
| 58 | + $replacementVars = array( |
|
| 59 | 59 | 'DBASE' => $modx->db->config['dbase'], |
| 60 | 60 | 'PREFIX' => $modx->db->config['table_prefix'] |
| 61 | 61 | ); |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | break; |
| 97 | 97 | |
| 98 | 98 | case 'DIRECTORY' : |
| 99 | - $files = array (); |
|
| 100 | - $path = $modx->config['base_path'] . $param; |
|
| 99 | + $files = array(); |
|
| 100 | + $path = $modx->config['base_path'].$param; |
|
| 101 | 101 | if (substr($path, -1, 1) != '/') { |
| 102 | 102 | $path .= '/'; |
| 103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param $file |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | -function ProcessFile($file) { |
|
| 132 | +function ProcessFile($file){ |
|
| 133 | 133 | // get the file |
| 134 | 134 | $buffer = @file_get_contents($file); |
| 135 | 135 | if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | global $BINDINGS; |
| 148 | 148 | $binding_array = array(); |
| 149 | - foreach($BINDINGS as $cmd) |
|
| 149 | + foreach ($BINDINGS as $cmd) |
|
| 150 | 150 | { |
| 151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
| 151 | + if (strpos($binding_string, '@'.$cmd) === 0) |
|
| 152 | 152 | { |
| 153 | - $code = substr($binding_string,strlen($cmd)+1); |
|
| 154 | - $binding_array = array($cmd,trim($code)); |
|
| 153 | + $code = substr($binding_string, strlen($cmd) + 1); |
|
| 154 | + $binding_array = array($cmd, trim($code)); |
|
| 155 | 155 | break; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | if (strpos($param, '[*') !== false) { |
| 173 | 173 | $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
| 174 | 174 | foreach ($matches[0] as $i=>$match) { |
| 175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 175 | + if (isset($tvsArray[$matches[1][$i]])) { |
|
| 176 | + if (is_array($tvsArray[$matches[1][$i]])) { |
|
| 177 | 177 | $value = $tvsArray[$matches[1][$i]]['value']; |
| 178 | 178 | $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
| 179 | 179 | } else { |
| 180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 180 | + $value = $tvsArray[$matches[1][$i]]; |
|
| 181 | 181 | } |
| 182 | 182 | $param = str_replace($match, $value, $param); |
| 183 | 183 | } |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | * @param array $tvsArray |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
| 25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) |
|
| 26 | +{ |
|
| 26 | 27 | $modx = evolutionCMS(); |
| 27 | 28 | $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
| 28 | 29 | $nvalue = trim($value); |
| 29 | - if (substr($nvalue, 0, 1) != '@') |
|
| 30 | - return $value; |
|
| 31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 30 | + if (substr($nvalue, 0, 1) != '@') { |
|
| 31 | + return $value; |
|
| 32 | + } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
| 32 | 33 | return '@Bindings is disabled.'; |
| 33 | - } |
|
| 34 | - else { |
|
| 34 | + } else { |
|
| 35 | 35 | list ($cmd, $param) = ParseCommand($nvalue); |
| 36 | 36 | $cmd = trim($cmd); |
| 37 | 37 | $param = parseTvValues($param, $tvsArray); |
@@ -47,10 +47,11 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | case "DOCUMENT" : // retrieve a document and process it's content |
| 49 | 49 | $rs = $modx->getDocument($param); |
| 50 | - if (is_array($rs)) |
|
| 51 | - $output = $rs['content']; |
|
| 52 | - else |
|
| 53 | - $output = "Unable to locate document $param"; |
|
| 50 | + if (is_array($rs)) { |
|
| 51 | + $output = $rs['content']; |
|
| 52 | + } else { |
|
| 53 | + $output = "Unable to locate document $param"; |
|
| 54 | + } |
|
| 54 | 55 | break; |
| 55 | 56 | |
| 56 | 57 | case "SELECT" : // selects a record from the cms database |
@@ -80,8 +81,10 @@ discard block |
||
| 80 | 81 | |
| 81 | 82 | // Grab document regardless of publish status |
| 82 | 83 | $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published'); |
| 83 | - if ($doc['parent'] != 0 && !$doc['published']) |
|
| 84 | - continue; // hide unpublished docs if we're not at the top |
|
| 84 | + if ($doc['parent'] != 0 && !$doc['published']) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + // hide unpublished docs if we're not at the top |
|
| 85 | 88 | |
| 86 | 89 | $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']); |
| 87 | 90 | |
@@ -129,10 +132,13 @@ discard block |
||
| 129 | 132 | * @param $file |
| 130 | 133 | * @return string |
| 131 | 134 | */ |
| 132 | -function ProcessFile($file) { |
|
| 135 | +function ProcessFile($file) |
|
| 136 | +{ |
|
| 133 | 137 | // get the file |
| 134 | 138 | $buffer = @file_get_contents($file); |
| 135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 139 | + if ($buffer === false) { |
|
| 140 | + $buffer = " Could not retrieve document '$file'."; |
|
| 141 | + } |
|
| 136 | 142 | return $buffer; |
| 137 | 143 | } |
| 138 | 144 | |
@@ -146,10 +152,8 @@ discard block |
||
| 146 | 152 | { |
| 147 | 153 | global $BINDINGS; |
| 148 | 154 | $binding_array = array(); |
| 149 | - foreach($BINDINGS as $cmd) |
|
| 150 | - { |
|
| 151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
| 152 | - { |
|
| 155 | + foreach($BINDINGS as $cmd) { |
|
| 156 | + if(strpos($binding_string,'@'.$cmd)===0) { |
|
| 153 | 157 | $code = substr($binding_string,strlen($cmd)+1); |
| 154 | 158 | $binding_array = array($cmd,trim($code)); |
| 155 | 159 | break; |
@@ -21,320 +21,320 @@ discard block |
||
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | - $value = ProcessTVCommand($value, $name, $docid); |
|
| 24 | + $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | + $value = ProcessTVCommand($value, $name, $docid); |
|
| 26 | 26 | |
| 27 | - $params = array(); |
|
| 28 | - if($paramstring) { |
|
| 29 | - $cp = explode("&", $paramstring); |
|
| 30 | - foreach($cp as $p => $v) { |
|
| 31 | - $v = trim($v); // trim |
|
| 32 | - $ar = explode("=", $v); |
|
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 34 | - $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 27 | + $params = array(); |
|
| 28 | + if($paramstring) { |
|
| 29 | + $cp = explode("&", $paramstring); |
|
| 30 | + foreach($cp as $p => $v) { |
|
| 31 | + $v = trim($v); // trim |
|
| 32 | + $ar = explode("=", $v); |
|
| 33 | + if(is_array($ar) && count($ar) == 2) { |
|
| 34 | + $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $id = "tv$name"; |
|
| 40 | - switch($format) { |
|
| 41 | - case 'image': |
|
| 42 | - $images = parseInput($value, '||', 'array'); |
|
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 45 | - $image = explode('==', $image); |
|
| 46 | - } |
|
| 47 | - $src = $image[0]; |
|
| 39 | + $id = "tv$name"; |
|
| 40 | + switch($format) { |
|
| 41 | + case 'image': |
|
| 42 | + $images = parseInput($value, '||', 'array'); |
|
| 43 | + foreach($images as $image) { |
|
| 44 | + if(!is_array($image)) { |
|
| 45 | + $image = explode('==', $image); |
|
| 46 | + } |
|
| 47 | + $src = $image[0]; |
|
| 48 | 48 | |
| 49 | - if($src) { |
|
| 50 | - // We have a valid source |
|
| 51 | - $attributes = ''; |
|
| 52 | - $attr = array( |
|
| 53 | - 'class' => $params['class'], |
|
| 54 | - 'src' => $src, |
|
| 55 | - 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | - 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | - 'style' => $params['style'] |
|
| 58 | - ); |
|
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | - $attr['align'] = $params['align']; |
|
| 61 | - } |
|
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 49 | + if($src) { |
|
| 50 | + // We have a valid source |
|
| 51 | + $attributes = ''; |
|
| 52 | + $attr = array( |
|
| 53 | + 'class' => $params['class'], |
|
| 54 | + 'src' => $src, |
|
| 55 | + 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | + 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | + 'style' => $params['style'] |
|
| 58 | + ); |
|
| 59 | + if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | + $attr['align'] = $params['align']; |
|
| 61 | + } |
|
| 62 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + $attributes .= ' ' . $params['attrib']; |
|
| 64 | 64 | |
| 65 | - // Output the image with attributes |
|
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - break; |
|
| 65 | + // Output the image with attributes |
|
| 66 | + $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + break; |
|
| 70 | 70 | |
| 71 | - case "delim": // display as delimitted list |
|
| 72 | - $value = parseInput($value, "||"); |
|
| 73 | - $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | - if($p == "\\n") { |
|
| 75 | - $p = "\n"; |
|
| 76 | - } |
|
| 77 | - $o = str_replace("||", $p, $value); |
|
| 78 | - break; |
|
| 71 | + case "delim": // display as delimitted list |
|
| 72 | + $value = parseInput($value, "||"); |
|
| 73 | + $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | + if($p == "\\n") { |
|
| 75 | + $p = "\n"; |
|
| 76 | + } |
|
| 77 | + $o = str_replace("||", $p, $value); |
|
| 78 | + break; |
|
| 79 | 79 | |
| 80 | - case "string": |
|
| 81 | - $value = parseInput($value); |
|
| 82 | - $format = strtolower($params['format']); |
|
| 83 | - if($format == 'upper case') { |
|
| 84 | - $o = strtoupper($value); |
|
| 85 | - } else if($format == 'lower case') { |
|
| 86 | - $o = strtolower($value); |
|
| 87 | - } else if($format == 'sentence case') { |
|
| 88 | - $o = ucfirst($value); |
|
| 89 | - } else if($format == 'capitalize') { |
|
| 90 | - $o = ucwords($value); |
|
| 91 | - } else { |
|
| 92 | - $o = $value; |
|
| 93 | - } |
|
| 94 | - break; |
|
| 80 | + case "string": |
|
| 81 | + $value = parseInput($value); |
|
| 82 | + $format = strtolower($params['format']); |
|
| 83 | + if($format == 'upper case') { |
|
| 84 | + $o = strtoupper($value); |
|
| 85 | + } else if($format == 'lower case') { |
|
| 86 | + $o = strtolower($value); |
|
| 87 | + } else if($format == 'sentence case') { |
|
| 88 | + $o = ucfirst($value); |
|
| 89 | + } else if($format == 'capitalize') { |
|
| 90 | + $o = ucwords($value); |
|
| 91 | + } else { |
|
| 92 | + $o = $value; |
|
| 93 | + } |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | - case "date": |
|
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 99 | - $value = 'now'; |
|
| 100 | - } |
|
| 101 | - $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | - $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | - $o = strftime($p, $timestamp); |
|
| 104 | - } else { |
|
| 105 | - $value = ''; |
|
| 106 | - } |
|
| 107 | - break; |
|
| 96 | + case "date": |
|
| 97 | + if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if(empty($value)) { |
|
| 99 | + $value = 'now'; |
|
| 100 | + } |
|
| 101 | + $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | + $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | + $o = strftime($p, $timestamp); |
|
| 104 | + } else { |
|
| 105 | + $value = ''; |
|
| 106 | + } |
|
| 107 | + break; |
|
| 108 | 108 | |
| 109 | - case "hyperlink": |
|
| 110 | - $value = parseInput($value, "||", "array"); |
|
| 111 | - $o = ''; |
|
| 112 | - $countValue = count($value); |
|
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 114 | - list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | - if(!$url) { |
|
| 116 | - $url = $name; |
|
| 117 | - } |
|
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 120 | - $o .= '<br />'; |
|
| 121 | - } |
|
| 122 | - $attributes = ''; |
|
| 123 | - // setup the link attributes |
|
| 124 | - $attr = array( |
|
| 125 | - 'href' => $url, |
|
| 126 | - 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | - 'class' => $params['class'], |
|
| 128 | - 'style' => $params['style'], |
|
| 129 | - 'target' => $params['target'], |
|
| 130 | - ); |
|
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 109 | + case "hyperlink": |
|
| 110 | + $value = parseInput($value, "||", "array"); |
|
| 111 | + $o = ''; |
|
| 112 | + $countValue = count($value); |
|
| 113 | + for($i = 0; $i < $countValue; $i++) { |
|
| 114 | + list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | + if(!$url) { |
|
| 116 | + $url = $name; |
|
| 117 | + } |
|
| 118 | + if($url) { |
|
| 119 | + if($o) { |
|
| 120 | + $o .= '<br />'; |
|
| 121 | + } |
|
| 122 | + $attributes = ''; |
|
| 123 | + // setup the link attributes |
|
| 124 | + $attr = array( |
|
| 125 | + 'href' => $url, |
|
| 126 | + 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | + 'class' => $params['class'], |
|
| 128 | + 'style' => $params['style'], |
|
| 129 | + 'target' => $params['target'], |
|
| 130 | + ); |
|
| 131 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | - // Output the link |
|
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - break; |
|
| 134 | + // Output the link |
|
| 135 | + $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + break; |
|
| 139 | 139 | |
| 140 | - case "htmltag": |
|
| 141 | - $value = parseInput($value, "||", "array"); |
|
| 142 | - $tagid = $params['tagid']; |
|
| 143 | - $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | - $o = ''; |
|
| 145 | - // Loop through a list of tags |
|
| 140 | + case "htmltag": |
|
| 141 | + $value = parseInput($value, "||", "array"); |
|
| 142 | + $tagid = $params['tagid']; |
|
| 143 | + $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | + $o = ''; |
|
| 145 | + // Loop through a list of tags |
|
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 148 | - $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | - if(!$tagvalue) { |
|
| 150 | - continue; |
|
| 151 | - } |
|
| 147 | + for($i = 0; $i < $countValue; $i++) { |
|
| 148 | + $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | + if(!$tagvalue) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $attributes = ''; |
|
| 154 | - $attr = array( |
|
| 155 | - 'id' => ($tagid ? $tagid : $id), |
|
| 156 | - // 'tv' already added to id |
|
| 157 | - 'class' => $params['class'], |
|
| 158 | - 'style' => $params['style'], |
|
| 159 | - ); |
|
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 153 | + $attributes = ''; |
|
| 154 | + $attr = array( |
|
| 155 | + 'id' => ($tagid ? $tagid : $id), |
|
| 156 | + // 'tv' already added to id |
|
| 157 | + 'class' => $params['class'], |
|
| 158 | + 'style' => $params['style'], |
|
| 159 | + ); |
|
| 160 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | - // Output the HTML Tag |
|
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | - } |
|
| 166 | - break; |
|
| 163 | + // Output the HTML Tag |
|
| 164 | + $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | + } |
|
| 166 | + break; |
|
| 167 | 167 | |
| 168 | - case "richtext": |
|
| 169 | - $value = parseInput($value); |
|
| 170 | - $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | - $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | - $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | - $o .= $modx->htmlspecialchars($value); |
|
| 175 | - $o .= '</textarea></div>'; |
|
| 176 | - $replace_richtext = array($id); |
|
| 177 | - // setup editors |
|
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | - // invoke OnRichTextEditorInit event |
|
| 180 | - $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | - 'editor' => $richtexteditor, |
|
| 182 | - 'elements' => $replace_richtext, |
|
| 183 | - 'forfrontend' => 1, |
|
| 184 | - 'width' => $w, |
|
| 185 | - 'height' => $h |
|
| 186 | - )); |
|
| 187 | - if(is_array($evtOut)) { |
|
| 188 | - $o .= implode("", $evtOut); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - break; |
|
| 168 | + case "richtext": |
|
| 169 | + $value = parseInput($value); |
|
| 170 | + $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | + $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | + $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | + $o .= $modx->htmlspecialchars($value); |
|
| 175 | + $o .= '</textarea></div>'; |
|
| 176 | + $replace_richtext = array($id); |
|
| 177 | + // setup editors |
|
| 178 | + if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | + // invoke OnRichTextEditorInit event |
|
| 180 | + $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | + 'editor' => $richtexteditor, |
|
| 182 | + 'elements' => $replace_richtext, |
|
| 183 | + 'forfrontend' => 1, |
|
| 184 | + 'width' => $w, |
|
| 185 | + 'height' => $h |
|
| 186 | + )); |
|
| 187 | + if(is_array($evtOut)) { |
|
| 188 | + $o .= implode("", $evtOut); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + break; |
|
| 192 | 192 | |
| 193 | - case "unixtime": |
|
| 194 | - $value = parseInput($value); |
|
| 195 | - $o = getUnixtimeFromDateString($value); |
|
| 196 | - break; |
|
| 193 | + case "unixtime": |
|
| 194 | + $value = parseInput($value); |
|
| 195 | + $o = getUnixtimeFromDateString($value); |
|
| 196 | + break; |
|
| 197 | 197 | |
| 198 | - case "viewport": |
|
| 199 | - $value = parseInput($value); |
|
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 202 | - $params['vpid'] = $id; |
|
| 203 | - } |
|
| 204 | - $sTag = "<iframe"; |
|
| 205 | - $eTag = "</iframe>"; |
|
| 206 | - $autoMode = "0"; |
|
| 207 | - $w = $params['width']; |
|
| 208 | - $h = $params['height']; |
|
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 210 | - $w = "100%"; |
|
| 211 | - $h = "100%"; |
|
| 212 | - } |
|
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 216 | - $autoMode = "1"; //width only |
|
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 219 | - } |
|
| 198 | + case "viewport": |
|
| 199 | + $value = parseInput($value); |
|
| 200 | + $id = '_' . time(); |
|
| 201 | + if(!$params['vpid']) { |
|
| 202 | + $params['vpid'] = $id; |
|
| 203 | + } |
|
| 204 | + $sTag = "<iframe"; |
|
| 205 | + $eTag = "</iframe>"; |
|
| 206 | + $autoMode = "0"; |
|
| 207 | + $w = $params['width']; |
|
| 208 | + $h = $params['height']; |
|
| 209 | + if($params['stretch'] == 'Yes') { |
|
| 210 | + $w = "100%"; |
|
| 211 | + $h = "100%"; |
|
| 212 | + } |
|
| 213 | + if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if($params['awidth'] == 'Yes') { |
|
| 216 | + $autoMode = "1"; //width only |
|
| 217 | + } else if($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | - 'name' => 'viewport', |
|
| 223 | - 'version' => '0', |
|
| 224 | - 'plaintext' => false |
|
| 225 | - )); |
|
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 229 | - } |
|
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 232 | - } |
|
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 235 | - } |
|
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | - $o .= ">"; |
|
| 240 | - $o .= $eTag; |
|
| 241 | - break; |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | + 'name' => 'viewport', |
|
| 223 | + 'version' => '0', |
|
| 224 | + 'plaintext' => false |
|
| 225 | + )); |
|
| 226 | + $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | + if($params['class']) { |
|
| 228 | + $o .= " class='" . $params['class'] . "' "; |
|
| 229 | + } |
|
| 230 | + if($params['style']) { |
|
| 231 | + $o .= " style='" . $params['style'] . "' "; |
|
| 232 | + } |
|
| 233 | + if($params['attrib']) { |
|
| 234 | + $o .= $params['attrib'] . " "; |
|
| 235 | + } |
|
| 236 | + $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | + $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | + $o .= ">"; |
|
| 240 | + $o .= $eTag; |
|
| 241 | + break; |
|
| 242 | 242 | |
| 243 | - case "datagrid": |
|
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | - $grd = new DataGrid('', $value); |
|
| 243 | + case "datagrid": |
|
| 244 | + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | + $grd = new DataGrid('', $value); |
|
| 246 | 246 | |
| 247 | - $grd->noRecordMsg = $params['egmsg']; |
|
| 247 | + $grd->noRecordMsg = $params['egmsg']; |
|
| 248 | 248 | |
| 249 | - $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | - $grd->cssClass = $params['tblc']; |
|
| 251 | - $grd->itemClass = $params['itmc']; |
|
| 252 | - $grd->altItemClass = $params['aitmc']; |
|
| 249 | + $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | + $grd->cssClass = $params['tblc']; |
|
| 251 | + $grd->itemClass = $params['itmc']; |
|
| 252 | + $grd->altItemClass = $params['aitmc']; |
|
| 253 | 253 | |
| 254 | - $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | - $grd->cssStyle = $params['tbls']; |
|
| 256 | - $grd->itemStyle = $params['itms']; |
|
| 257 | - $grd->altItemStyle = $params['aitms']; |
|
| 254 | + $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | + $grd->cssStyle = $params['tbls']; |
|
| 256 | + $grd->itemStyle = $params['itms']; |
|
| 257 | + $grd->altItemStyle = $params['aitms']; |
|
| 258 | 258 | |
| 259 | - $grd->columns = $params['cols']; |
|
| 260 | - $grd->fields = $params['flds']; |
|
| 261 | - $grd->colWidths = $params['cwidth']; |
|
| 262 | - $grd->colAligns = $params['calign']; |
|
| 263 | - $grd->colColors = $params['ccolor']; |
|
| 264 | - $grd->colTypes = $params['ctype']; |
|
| 259 | + $grd->columns = $params['cols']; |
|
| 260 | + $grd->fields = $params['flds']; |
|
| 261 | + $grd->colWidths = $params['cwidth']; |
|
| 262 | + $grd->colAligns = $params['calign']; |
|
| 263 | + $grd->colColors = $params['ccolor']; |
|
| 264 | + $grd->colTypes = $params['ctype']; |
|
| 265 | 265 | |
| 266 | - $grd->cellPadding = $params['cpad']; |
|
| 267 | - $grd->cellSpacing = $params['cspace']; |
|
| 268 | - $grd->header = $params['head']; |
|
| 269 | - $grd->footer = $params['foot']; |
|
| 270 | - $grd->pageSize = $params['psize']; |
|
| 271 | - $grd->pagerLocation = $params['ploc']; |
|
| 272 | - $grd->pagerClass = $params['pclass']; |
|
| 273 | - $grd->pagerStyle = $params['pstyle']; |
|
| 274 | - $o = $grd->render(); |
|
| 275 | - break; |
|
| 266 | + $grd->cellPadding = $params['cpad']; |
|
| 267 | + $grd->cellSpacing = $params['cspace']; |
|
| 268 | + $grd->header = $params['head']; |
|
| 269 | + $grd->footer = $params['foot']; |
|
| 270 | + $grd->pageSize = $params['psize']; |
|
| 271 | + $grd->pagerLocation = $params['ploc']; |
|
| 272 | + $grd->pagerClass = $params['pclass']; |
|
| 273 | + $grd->pagerStyle = $params['pstyle']; |
|
| 274 | + $o = $grd->render(); |
|
| 275 | + break; |
|
| 276 | 276 | |
| 277 | - case 'htmlentities': |
|
| 278 | - $value = parseInput($value); |
|
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | - // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | - $value = str_replace('||', '', $value); |
|
| 282 | - } |
|
| 283 | - $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | - break; |
|
| 277 | + case 'htmlentities': |
|
| 278 | + $value = parseInput($value); |
|
| 279 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | + // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | + $value = str_replace('||', '', $value); |
|
| 282 | + } |
|
| 283 | + $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | + break; |
|
| 285 | 285 | |
| 286 | - case 'custom_widget': |
|
| 287 | - $widget_output = ''; |
|
| 288 | - $o = ''; |
|
| 289 | - /* If we are loading a file */ |
|
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 294 | - } else { |
|
| 295 | - $widget_output = file_get_contents($file_name); |
|
| 296 | - } |
|
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 301 | - } else { |
|
| 302 | - /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | - include $file_name; |
|
| 304 | - } |
|
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | - $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | - $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | - $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | - $widget_output = eval($eval_str); |
|
| 311 | - } elseif($value !== '') { |
|
| 312 | - $widget_output = $params['output']; |
|
| 313 | - } else { |
|
| 314 | - $widget_output = ''; |
|
| 315 | - } |
|
| 316 | - if(is_string($widget_output)) { |
|
| 317 | - $_ = $modx->config['enable_filter']; |
|
| 318 | - $modx->config['enable_filter'] = 1; |
|
| 319 | - $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | - $modx->config['enable_filter'] = $_; |
|
| 321 | - $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | - } else { |
|
| 323 | - $o = $widget_output; |
|
| 324 | - } |
|
| 325 | - break; |
|
| 286 | + case 'custom_widget': |
|
| 287 | + $widget_output = ''; |
|
| 288 | + $o = ''; |
|
| 289 | + /* If we are loading a file */ |
|
| 290 | + if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | + if(!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name . ' does not exist'; |
|
| 294 | + } else { |
|
| 295 | + $widget_output = file_get_contents($file_name); |
|
| 296 | + } |
|
| 297 | + } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | + if(!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name . ' does not exist'; |
|
| 301 | + } else { |
|
| 302 | + /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | + include $file_name; |
|
| 304 | + } |
|
| 305 | + } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | + $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | + $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | + } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | + $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | + $widget_output = eval($eval_str); |
|
| 311 | + } elseif($value !== '') { |
|
| 312 | + $widget_output = $params['output']; |
|
| 313 | + } else { |
|
| 314 | + $widget_output = ''; |
|
| 315 | + } |
|
| 316 | + if(is_string($widget_output)) { |
|
| 317 | + $_ = $modx->config['enable_filter']; |
|
| 318 | + $modx->config['enable_filter'] = 1; |
|
| 319 | + $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | + $modx->config['enable_filter'] = $_; |
|
| 321 | + $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | + } else { |
|
| 323 | + $o = $widget_output; |
|
| 324 | + } |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | - default: |
|
| 328 | - $value = parseInput($value); |
|
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | - // add separator |
|
| 331 | - $value = explode('||', $value); |
|
| 332 | - $value = implode($sep, $value); |
|
| 333 | - } |
|
| 334 | - $o = $value; |
|
| 335 | - break; |
|
| 336 | - } |
|
| 337 | - return $o; |
|
| 327 | + default: |
|
| 328 | + $value = parseInput($value); |
|
| 329 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | + // add separator |
|
| 331 | + $value = explode('||', $value); |
|
| 332 | + $value = implode($sep, $value); |
|
| 333 | + } |
|
| 334 | + $o = $value; |
|
| 335 | + break; |
|
| 336 | + } |
|
| 337 | + return $o; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | 344 | function decodeParamValue($s) { |
| 345 | - $s = str_replace("%3D", '=', $s); // = |
|
| 346 | - return str_replace("%26", '&', $s); // & |
|
| 345 | + $s = str_replace("%3D", '=', $s); // = |
|
| 346 | + return str_replace("%26", '&', $s); // & |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -357,19 +357,19 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
| 359 | 359 | $modx = evolutionCMS(); |
| 360 | - if($modx->db->isResult($src)) { |
|
| 361 | - // must be a recordset |
|
| 362 | - $rows = array(); |
|
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | - return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | - } else { |
|
| 366 | - // must be a text |
|
| 367 | - if($type == "array") { |
|
| 368 | - return explode($delim, $src); |
|
| 369 | - } else { |
|
| 370 | - return $src; |
|
| 371 | - } |
|
| 372 | - } |
|
| 360 | + if($modx->db->isResult($src)) { |
|
| 361 | + // must be a recordset |
|
| 362 | + $rows = array(); |
|
| 363 | + while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | + return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | + } else { |
|
| 366 | + // must be a text |
|
| 367 | + if($type == "array") { |
|
| 368 | + return explode($delim, $src); |
|
| 369 | + } else { |
|
| 370 | + return $src; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -377,21 +377,21 @@ discard block |
||
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | 379 | function getUnixtimeFromDateString($value) { |
| 380 | - $timestamp = false; |
|
| 381 | - // Check for MySQL or legacy style date |
|
| 382 | - $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | - $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | - $matches = array(); |
|
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - // If those didn't work, use strtotime to figure out the date |
|
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 394 | - $timestamp = strtotime($value); |
|
| 395 | - } |
|
| 396 | - return $timestamp; |
|
| 380 | + $timestamp = false; |
|
| 381 | + // Check for MySQL or legacy style date |
|
| 382 | + $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | + $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | + $matches = array(); |
|
| 385 | + if(strpos($value, '-') !== false) { |
|
| 386 | + if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | + } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + // If those didn't work, use strtotime to figure out the date |
|
| 393 | + if($timestamp === false || $timestamp === -1) { |
|
| 394 | + $timestamp = strtotime($value); |
|
| 395 | + } |
|
| 396 | + return $timestamp; |
|
| 397 | 397 | } |
@@ -15,38 +15,38 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
| 19 | 19 | |
| 20 | 20 | $modx = evolutionCMS(); |
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
| 26 | 26 | |
| 27 | 27 | $params = array(); |
| 28 | - if($paramstring) { |
|
| 28 | + if ($paramstring) { |
|
| 29 | 29 | $cp = explode("&", $paramstring); |
| 30 | - foreach($cp as $p => $v) { |
|
| 30 | + foreach ($cp as $p => $v) { |
|
| 31 | 31 | $v = trim($v); // trim |
| 32 | 32 | $ar = explode("=", $v); |
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 33 | + if (is_array($ar) && count($ar) == 2) { |
|
| 34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $id = "tv$name"; |
| 40 | - switch($format) { |
|
| 40 | + switch ($format) { |
|
| 41 | 41 | case 'image': |
| 42 | 42 | $images = parseInput($value, '||', 'array'); |
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 43 | + foreach ($images as $image) { |
|
| 44 | + if (!is_array($image)) { |
|
| 45 | 45 | $image = explode('==', $image); |
| 46 | 46 | } |
| 47 | 47 | $src = $image[0]; |
| 48 | 48 | |
| 49 | - if($src) { |
|
| 49 | + if ($src) { |
|
| 50 | 50 | // We have a valid source |
| 51 | 51 | $attributes = ''; |
| 52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
| 57 | 57 | 'style' => $params['style'] |
| 58 | 58 | ); |
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | 60 | $attr['align'] = $params['align']; |
| 61 | 61 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 63 | + $attributes .= ' '.$params['attrib']; |
|
| 64 | 64 | |
| 65 | 65 | // Output the image with attributes |
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | case "delim": // display as delimitted list |
| 72 | 72 | $value = parseInput($value, "||"); |
| 73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
| 74 | - if($p == "\\n") { |
|
| 74 | + if ($p == "\\n") { |
|
| 75 | 75 | $p = "\n"; |
| 76 | 76 | } |
| 77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | case "string": |
| 81 | 81 | $value = parseInput($value); |
| 82 | 82 | $format = strtolower($params['format']); |
| 83 | - if($format == 'upper case') { |
|
| 83 | + if ($format == 'upper case') { |
|
| 84 | 84 | $o = strtoupper($value); |
| 85 | - } else if($format == 'lower case') { |
|
| 85 | + } else if ($format == 'lower case') { |
|
| 86 | 86 | $o = strtolower($value); |
| 87 | - } else if($format == 'sentence case') { |
|
| 87 | + } else if ($format == 'sentence case') { |
|
| 88 | 88 | $o = ucfirst($value); |
| 89 | - } else if($format == 'capitalize') { |
|
| 89 | + } else if ($format == 'capitalize') { |
|
| 90 | 90 | $o = ucwords($value); |
| 91 | 91 | } else { |
| 92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | break; |
| 95 | 95 | |
| 96 | 96 | case "date": |
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if (empty($value)) { |
|
| 99 | 99 | $value = 'now'; |
| 100 | 100 | } |
| 101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | $value = parseInput($value, "||", "array"); |
| 111 | 111 | $o = ''; |
| 112 | 112 | $countValue = count($value); |
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 113 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
| 115 | - if(!$url) { |
|
| 115 | + if (!$url) { |
|
| 116 | 116 | $url = $name; |
| 117 | 117 | } |
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 118 | + if ($url) { |
|
| 119 | + if ($o) { |
|
| 120 | 120 | $o .= '<br />'; |
| 121 | 121 | } |
| 122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | 'style' => $params['style'], |
| 129 | 129 | 'target' => $params['target'], |
| 130 | 130 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | 134 | // Output the link |
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | $o = ''; |
| 145 | 145 | // Loop through a list of tags |
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 147 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
| 149 | - if(!$tagvalue) { |
|
| 149 | + if (!$tagvalue) { |
|
| 150 | 150 | continue; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | 'class' => $params['class'], |
| 158 | 158 | 'style' => $params['style'], |
| 159 | 159 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | 163 | // Output the HTML Tag |
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
| 171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
| 172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
| 174 | 174 | $o .= $modx->htmlspecialchars($value); |
| 175 | 175 | $o .= '</textarea></div>'; |
| 176 | 176 | $replace_richtext = array($id); |
| 177 | 177 | // setup editors |
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | 179 | // invoke OnRichTextEditorInit event |
| 180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
| 181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | 'width' => $w, |
| 185 | 185 | 'height' => $h |
| 186 | 186 | )); |
| 187 | - if(is_array($evtOut)) { |
|
| 187 | + if (is_array($evtOut)) { |
|
| 188 | 188 | $o .= implode("", $evtOut); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | case "viewport": |
| 199 | 199 | $value = parseInput($value); |
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 200 | + $id = '_'.time(); |
|
| 201 | + if (!$params['vpid']) { |
|
| 202 | 202 | $params['vpid'] = $id; |
| 203 | 203 | } |
| 204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
| 206 | 206 | $autoMode = "0"; |
| 207 | 207 | $w = $params['width']; |
| 208 | 208 | $h = $params['height']; |
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 209 | + if ($params['stretch'] == 'Yes') { |
|
| 210 | 210 | $w = "100%"; |
| 211 | 211 | $h = "100%"; |
| 212 | 212 | } |
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if ($params['awidth'] == 'Yes') { |
|
| 216 | 216 | $autoMode = "1"; //width only |
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 217 | + } else if ($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
| 222 | 222 | 'name' => 'viewport', |
| 223 | 223 | 'version' => '0', |
| 224 | 224 | 'plaintext' => false |
| 225 | 225 | )); |
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
| 227 | + if ($params['class']) { |
|
| 228 | + $o .= " class='".$params['class']."' "; |
|
| 229 | 229 | } |
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 230 | + if ($params['style']) { |
|
| 231 | + $o .= " style='".$params['style']."' "; |
|
| 232 | 232 | } |
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 233 | + if ($params['attrib']) { |
|
| 234 | + $o .= $params['attrib']." "; |
|
| 235 | 235 | } |
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
| 237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
| 239 | 239 | $o .= ">"; |
| 240 | 240 | $o .= $eTag; |
| 241 | 241 | break; |
| 242 | 242 | |
| 243 | 243 | case "datagrid": |
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
| 245 | 245 | $grd = new DataGrid('', $value); |
| 246 | 246 | |
| 247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | case 'htmlentities': |
| 278 | 278 | $value = parseInput($value); |
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
| 281 | 281 | $value = str_replace('||', '', $value); |
| 282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
| 287 | 287 | $widget_output = ''; |
| 288 | 288 | $o = ''; |
| 289 | 289 | /* If we are loading a file */ |
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
| 292 | + if (!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name.' does not exist'; |
|
| 294 | 294 | } else { |
| 295 | 295 | $widget_output = file_get_contents($file_name); |
| 296 | 296 | } |
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
| 299 | + if (!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name.' does not exist'; |
|
| 301 | 301 | } else { |
| 302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
| 303 | 303 | include $file_name; |
| 304 | 304 | } |
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
| 307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
| 310 | 310 | $widget_output = eval($eval_str); |
| 311 | - } elseif($value !== '') { |
|
| 311 | + } elseif ($value !== '') { |
|
| 312 | 312 | $widget_output = $params['output']; |
| 313 | 313 | } else { |
| 314 | 314 | $widget_output = ''; |
| 315 | 315 | } |
| 316 | - if(is_string($widget_output)) { |
|
| 316 | + if (is_string($widget_output)) { |
|
| 317 | 317 | $_ = $modx->config['enable_filter']; |
| 318 | 318 | $modx->config['enable_filter'] = 1; |
| 319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | default: |
| 328 | 328 | $value = parseInput($value); |
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | 330 | // add separator |
| 331 | 331 | $value = explode('||', $value); |
| 332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param string $s |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 344 | +function decodeParamValue($s){ |
|
| 345 | 345 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 346 | return str_replace("%26", '&', $s); // & |
| 347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | * @param bool $columns |
| 356 | 356 | * @return array|string |
| 357 | 357 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
| 359 | 359 | $modx = evolutionCMS(); |
| 360 | - if($modx->db->isResult($src)) { |
|
| 360 | + if ($modx->db->isResult($src)) { |
|
| 361 | 361 | // must be a recordset |
| 362 | 362 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 365 | } else { |
| 366 | 366 | // must be a text |
| 367 | - if($type == "array") { |
|
| 367 | + if ($type == "array") { |
|
| 368 | 368 | return explode($delim, $src); |
| 369 | 369 | } else { |
| 370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
| 376 | 376 | * @param string $value |
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 379 | +function getUnixtimeFromDateString($value){ |
|
| 380 | 380 | $timestamp = false; |
| 381 | 381 | // Check for MySQL or legacy style date |
| 382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 384 | 384 | $matches = array(); |
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 385 | + if (strpos($value, '-') !== false) { |
|
| 386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
| 387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
| 389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | // If those didn't work, use strtotime to figure out the date |
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 393 | + if ($timestamp === false || $timestamp === -1) { |
|
| 394 | 394 | $timestamp = strtotime($value); |
| 395 | 395 | } |
| 396 | 396 | return $timestamp; |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | $modx = evolutionCMS(); |
| 21 | 22 | $o = ''; |
@@ -59,7 +60,9 @@ discard block |
||
| 59 | 60 | if(isset($params['align']) && $params['align'] != 'none') { |
| 60 | 61 | $attr['align'] = $params['align']; |
| 61 | 62 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + foreach($attr as $k => $v) { |
|
| 64 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 65 | + } |
|
| 63 | 66 | $attributes .= ' ' . $params['attrib']; |
| 64 | 67 | |
| 65 | 68 | // Output the image with attributes |
@@ -128,7 +131,9 @@ discard block |
||
| 128 | 131 | 'style' => $params['style'], |
| 129 | 132 | 'target' => $params['target'], |
| 130 | 133 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 134 | + foreach($attr as $k => $v) { |
|
| 135 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 136 | + } |
|
| 132 | 137 | $attributes .= ' ' . $params['attrib']; // add extra |
| 133 | 138 | |
| 134 | 139 | // Output the link |
@@ -157,7 +162,9 @@ discard block |
||
| 157 | 162 | 'class' => $params['class'], |
| 158 | 163 | 'style' => $params['style'], |
| 159 | 164 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 165 | + foreach($attr as $k => $v) { |
|
| 166 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 167 | + } |
|
| 161 | 168 | $attributes .= ' ' . $params['attrib']; // add extra |
| 162 | 169 | |
| 163 | 170 | // Output the HTML Tag |
@@ -341,7 +348,8 @@ discard block |
||
| 341 | 348 | * @param string $s |
| 342 | 349 | * @return string |
| 343 | 350 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 351 | +function decodeParamValue($s) |
|
| 352 | +{ |
|
| 345 | 353 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 354 | return str_replace("%26", '&', $s); // & |
| 347 | 355 | } |
@@ -355,12 +363,16 @@ discard block |
||
| 355 | 363 | * @param bool $columns |
| 356 | 364 | * @return array|string |
| 357 | 365 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 366 | +function parseInput($src, $delim = "||", $type = "string", $columns = true) |
|
| 367 | +{ |
|
| 368 | +// type can be: string, array |
|
| 359 | 369 | $modx = evolutionCMS(); |
| 360 | 370 | if($modx->db->isResult($src)) { |
| 361 | 371 | // must be a recordset |
| 362 | 372 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 373 | + while($cols = $modx->db->getRow($src, 'num')) { |
|
| 374 | + $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 375 | + } |
|
| 364 | 376 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 377 | } else { |
| 366 | 378 | // must be a text |
@@ -376,7 +388,8 @@ discard block |
||
| 376 | 388 | * @param string $value |
| 377 | 389 | * @return bool|false|int |
| 378 | 390 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 391 | +function getUnixtimeFromDateString($value) |
|
| 392 | +{ |
|
| 380 | 393 | $timestamp = false; |
| 381 | 394 | // Check for MySQL or legacy style date |
| 382 | 395 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |