@@ -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 | |
@@ -144,33 +144,33 @@ discard block |
||
| 144 | 144 | $algorithm = 'UNCRYPT'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $salt = md5($password . $seed); |
|
| 147 | + $salt = md5($password.$seed); |
|
| 148 | 148 | |
| 149 | 149 | switch ($algorithm) { |
| 150 | 150 | case 'BLOWFISH_Y': |
| 151 | - $salt = '$2y$07$' . substr($salt, 0, 22); |
|
| 151 | + $salt = '$2y$07$'.substr($salt, 0, 22); |
|
| 152 | 152 | break; |
| 153 | 153 | case 'BLOWFISH_A': |
| 154 | - $salt = '$2a$07$' . substr($salt, 0, 22); |
|
| 154 | + $salt = '$2a$07$'.substr($salt, 0, 22); |
|
| 155 | 155 | break; |
| 156 | 156 | case 'SHA512': |
| 157 | - $salt = '$6$' . substr($salt, 0, 16); |
|
| 157 | + $salt = '$6$'.substr($salt, 0, 16); |
|
| 158 | 158 | break; |
| 159 | 159 | case 'SHA256': |
| 160 | - $salt = '$5$' . substr($salt, 0, 16); |
|
| 160 | + $salt = '$5$'.substr($salt, 0, 16); |
|
| 161 | 161 | break; |
| 162 | 162 | case 'MD5': |
| 163 | - $salt = '$1$' . substr($salt, 0, 8); |
|
| 163 | + $salt = '$1$'.substr($salt, 0, 8); |
|
| 164 | 164 | break; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if ($algorithm !== 'UNCRYPT') { |
| 168 | - $password = sha1($password) . crypt($password, $salt); |
|
| 168 | + $password = sha1($password).crypt($password, $salt); |
|
| 169 | 169 | } else { |
| 170 | - $password = sha1($salt . $password); |
|
| 170 | + $password = sha1($salt.$password); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $result = strtolower($algorithm) . '>' . md5($salt . $password) . substr(md5($salt), 0, 8); |
|
| 173 | + $result = strtolower($algorithm).'>'.md5($salt.$password).substr(md5($salt), 0, 8); |
|
| 174 | 174 | |
| 175 | 175 | return $result; |
| 176 | 176 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $check_files = explode("\n", $check_files); |
| 253 | 253 | foreach ($check_files as $file) { |
| 254 | 254 | $file = trim($file); |
| 255 | - $file = MODX_BASE_PATH . $file; |
|
| 255 | + $file = MODX_BASE_PATH.$file; |
|
| 256 | 256 | if (!is_file($file)) { |
| 257 | 257 | continue; |
| 258 | 258 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $checksum = unserialize($checksum); |
| 276 | 276 | foreach ($check_files as $file) { |
| 277 | 277 | $file = trim($file); |
| 278 | - $filePath = MODX_BASE_PATH . $file; |
|
| 278 | + $filePath = MODX_BASE_PATH.$file; |
|
| 279 | 279 | if (!is_file($filePath)) { |
| 280 | 280 | continue; |
| 281 | 281 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | { |
| 295 | 295 | $modx = evolutionCMS(); |
| 296 | 296 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 297 | - $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','" . $modx->db->escape($checksum) . "')"; |
|
| 297 | + $sql = "REPLACE INTO {$tbl_system_settings} (setting_name, setting_value) VALUES ('sys_files_checksum','".$modx->db->escape($checksum)."')"; |
|
| 298 | 298 | $modx->db->query($sql); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -371,10 +371,10 @@ discard block |
||
| 371 | 371 | foreach ($settings as $key => $val) { |
| 372 | 372 | $f = array(); |
| 373 | 373 | $f['user'] = $_SESSION['mgrInternalKey']; |
| 374 | - $f['setting_name'] = '_LAST_' . $key; |
|
| 374 | + $f['setting_name'] = '_LAST_'.$key; |
|
| 375 | 375 | $f['setting_value'] = $val; |
| 376 | 376 | $f = $modx->db->escape($f); |
| 377 | - $f = "(`" . implode("`, `", array_keys($f)) . "`) VALUES('" . implode("', '", array_values($f)) . "')"; |
|
| 377 | + $f = "(`".implode("`, `", array_keys($f))."`) VALUES('".implode("', '", array_values($f))."')"; |
|
| 378 | 378 | $f .= " ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)"; |
| 379 | 379 | $modx->db->insert($f, $modx->getFullTableName('user_settings')); |
| 380 | 380 | } |
@@ -116,7 +116,8 @@ discard block |
||
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | 118 | public function getHashType($db_value = '') |
| 119 | - { // md5 | v1 | phpass |
|
| 119 | + { |
|
| 120 | +// md5 | v1 | phpass |
|
| 120 | 121 | $c = substr($db_value, 0, 1); |
| 121 | 122 | if ($c === '$') { |
| 122 | 123 | return 'phpass'; |
@@ -135,7 +136,8 @@ discard block |
||
| 135 | 136 | * @return string |
| 136 | 137 | */ |
| 137 | 138 | public function genV1Hash($password, $seed = '1') |
| 138 | - { // $seed is user_id basically |
|
| 139 | + { |
|
| 140 | +// $seed is user_id basically |
|
| 139 | 141 | $modx = evolutionCMS(); |
| 140 | 142 | |
| 141 | 143 | if (isset($modx->config['pwd_hash_algo']) && !empty($modx->config['pwd_hash_algo'])) { |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if( ! function_exists('evolutionCMS')) {
|
|
| 7 | +if (!function_exists('evolutionCMS')) {
|
|
| 8 | 8 | /** |
| 9 | 9 | * @return DocumentParser |
| 10 | 10 | */ |
| 11 | 11 | function evolutionCMS() |
| 12 | 12 | {
|
| 13 | - if( ! defined('MODX_CLASS')) {
|
|
| 14 | - if( ! class_exists('DocumentParser')) {
|
|
| 13 | + if (!defined('MODX_CLASS')) {
|
|
| 14 | + if (!class_exists('DocumentParser')) {
|
|
| 15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists');
|
| 16 | 16 | } |
| 17 | 17 | define('MODX_CLASS', 'DocumentParser');
|
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $_ = crc32(__FILE__); |
| 30 | 30 | $_ = sprintf('%u', $_);
|
| 31 | 31 | |
| 32 | - return 'evo' . base_convert($_, 10, 36); |
|
| 32 | + return 'evo'.base_convert($_, 10, 36); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | session_start(); |
| 51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
| 52 | 52 | if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
| 53 | - $cookieLifetime = (int)$_SESSION[$key]; |
|
| 53 | + $cookieLifetime = (int) $_SESSION[$key]; |
|
| 54 | 54 | if ($cookieLifetime) {
|
| 55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 56 | 56 | } |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if( ! function_exists('evolutionCMS')) {
|
|
| 7 | +if( ! function_exists('evolutionCMS')) { |
|
| 8 | 8 | /** |
| 9 | 9 | * @return DocumentParser |
| 10 | 10 | */ |
| 11 | - function evolutionCMS() |
|
| 12 | - {
|
|
| 13 | - if( ! defined('MODX_CLASS')) {
|
|
| 14 | - if( ! class_exists('DocumentParser')) {
|
|
| 11 | + function evolutionCMS() |
|
| 12 | + { |
|
| 13 | + if( ! defined('MODX_CLASS')) { |
|
| 14 | + if( ! class_exists('DocumentParser')) { |
|
| 15 | 15 | throw new RuntimeException('MODX_CLASS not defined and DocumentParser class not exists');
|
| 16 | 16 | } |
| 17 | 17 | define('MODX_CLASS', 'DocumentParser');
|
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | -function genEvoSessionName() |
|
| 28 | -{
|
|
| 27 | +function genEvoSessionName() |
|
| 28 | +{ |
|
| 29 | 29 | $_ = crc32(__FILE__); |
| 30 | 30 | $_ = sprintf('%u', $_);
|
| 31 | 31 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function startCMSSession() |
|
| 39 | -{
|
|
| 38 | +function startCMSSession() |
|
| 39 | +{ |
|
| 40 | 40 | |
| 41 | 41 | global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain; |
| 42 | 42 | |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 50 | 50 | session_start(); |
| 51 | 51 | $key = "modx.mgr.session.cookie.lifetime"; |
| 52 | - if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
|
|
| 52 | + if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) { |
|
| 53 | 53 | $cookieLifetime = (int)$_SESSION[$key]; |
| 54 | - if ($cookieLifetime) {
|
|
| 54 | + if ($cookieLifetime) { |
|
| 55 | 55 | $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime; |
| 56 | 56 | } |
| 57 | 57 | setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true); |
| 58 | 58 | } |
| 59 | - if (!isset($_SESSION['modx.session.created.time'])) {
|
|
| 59 | + if (!isset($_SESSION['modx.session.created.time'])) { |
|
| 60 | 60 | $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @param $session_name |
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | -function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 70 | -{
|
|
| 71 | - if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
|
|
| 69 | +function removeInvalidCmsSessionFromStorage(&$storage, $session_name) |
|
| 70 | +{ |
|
| 71 | + if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) { |
|
| 72 | 72 | unset($storage[$session_name]); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param $session_name |
| 78 | 78 | * @return void |
| 79 | 79 | */ |
| 80 | -function removeInvalidCmsSessionIds($session_name) |
|
| 81 | -{
|
|
| 80 | +function removeInvalidCmsSessionIds($session_name) |
|
| 81 | +{ |
|
| 82 | 82 | // session ids is invalid iff it is empty string |
| 83 | 83 | // storage priorioty can see in PHP source ext/session/session.c |
| 84 | 84 | removeInvalidCmsSessionFromStorage($_COOKIE, $session_name); |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | $action = "", |
| 37 | 37 | $itemid = "", |
| 38 | 38 | $itemname = "" |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | $modx = evolutionCMS(); |
| 41 | 41 | $this->entry['msg'] = $msg; // writes testmessage to the object |
| 42 | - $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 42 | + $this->entry['action'] = empty($action) ? $modx->manager->action : $action; // writes the action to the object |
|
| 43 | 43 | |
| 44 | 44 | // User Credentials |
| 45 | 45 | $this->entry['internalKey'] = $internalKey == "" ? $modx->getLoginUserID() : $internalKey; |
| 46 | 46 | $this->entry['username'] = $username == "" ? $modx->getLoginUserName() : $username; |
| 47 | 47 | |
| 48 | - $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int)$_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 48 | + $this->entry['itemId'] = (empty($itemid) && isset($_REQUEST['id'])) ? (int) $_REQUEST['id'] : $itemid; // writes the id to the object |
|
| 49 | 49 | if ($this->entry['itemId'] == 0) { |
| 50 | 50 | $this->entry['itemId'] = "-"; |
| 51 | 51 | } // to stop items having id 0 |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | $fields['message'] = $modx->db->escape($this->entry['msg']); |
| 94 | 94 | $insert_id = $modx->db->insert($fields, $tbl_manager_log); |
| 95 | 95 | if (!$insert_id) { |
| 96 | - $modx->messageQuit("Logging error: couldn't save log to table! Error code: " . $modx->db->getLastError()); |
|
| 96 | + $modx->messageQuit("Logging error: couldn't save log to table! Error code: ".$modx->db->getLastError()); |
|
| 97 | 97 | } else { |
| 98 | - $limit = (isset($modx->config['manager_log_limit'])) ? (int)$modx->config['manager_log_limit'] : 3000; |
|
| 99 | - $trim = (isset($modx->config['manager_log_trim'])) ? (int)$modx->config['manager_log_trim'] : 100; |
|
| 98 | + $limit = (isset($modx->config['manager_log_limit'])) ? (int) $modx->config['manager_log_limit'] : 3000; |
|
| 99 | + $trim = (isset($modx->config['manager_log_trim'])) ? (int) $modx->config['manager_log_trim'] : 100; |
|
| 100 | 100 | if (($insert_id % $trim) === 0) { |
| 101 | 101 | $modx->rotate_log('manager_log', $limit, $trim); |
| 102 | 102 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class DATEPICKER {
|
| 4 | - function __construct() {
|
|
| 5 | - } |
|
| 4 | + function __construct() {
|
|
| 5 | + } |
|
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 8 | - $modx = evolutionCMS(); global $_lang; |
|
| 7 | + function getDP() {
|
|
| 8 | + $modx = evolutionCMS(); global $_lang; |
|
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | - return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | - } |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | + } |
|
| 13 | 13 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class DATEPICKER {
|
|
| 4 | - function __construct() {
|
|
| 3 | +class DATEPICKER{
|
|
| 4 | + function __construct(){
|
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 7 | + function getDP(){
|
|
| 8 | 8 | $modx = evolutionCMS(); global $_lang; |
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
|
| 11 | 11 | return $modx->parseText($tpl, $_lang, '[%', '%]'); |
| 12 | 12 | } |
| 13 | 13 | } |
@@ -1,10 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class DATEPICKER {
|
|
| 4 | - function __construct() {
|
|
| 3 | +class DATEPICKER |
|
| 4 | +{ |
|
| 5 | + function __construct() |
|
| 6 | + { |
|
| 5 | 7 | } |
| 6 | 8 | |
| 7 | - function getDP() {
|
|
| 9 | + function getDP() |
|
| 10 | + { |
|
| 8 | 11 | $modx = evolutionCMS(); global $_lang; |
| 9 | 12 | |
| 10 | 13 | $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 3 | - function __construct() { |
|
| 2 | +class DATEPICKER{ |
|
| 3 | + function __construct(){ |
|
| 4 | 4 | } |
| 5 | - function getDP() { |
|
| 5 | + function getDP(){ |
|
| 6 | 6 | $modx = evolutionCMS(); global$_lang; |
| 7 | 7 | |
| 8 | 8 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
| 9 | - return $modx->parseText($tpl,$_lang,'[%','%]'); |
|
| 9 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 10 | 10 | } |
| 11 | 11 | } |
@@ -1,8 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | -class DATEPICKER { |
|
| 3 | - function __construct() { |
|
| 2 | +class DATEPICKER |
|
| 3 | +{ |
|
| 4 | + function __construct() |
|
| 5 | + { |
|
| 4 | 6 | } |
| 5 | - function getDP() { |
|
| 7 | + function getDP() |
|
| 8 | + { |
|
| 6 | 9 | $modx = evolutionCMS(); global$_lang; |
| 7 | 10 | |
| 8 | 11 | $tpl = file_get_contents(dirname(__FILE__).'/datepicker.tpl'); |
@@ -3,12 +3,12 @@ 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 | if(!$modx->hasPermission('delete_document')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /************ webber ********/ |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
| 33 | 33 | |
| 34 | 34 | if(!$udperms->checkPermissions()) { |
| 35 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 35 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // get the timestamp on which the document was deleted. |
| 39 | 39 | $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1"); |
| 40 | 40 | $deltime = $modx->db->getValue($rs); |
| 41 | 41 | if(!$deltime) { |
| 42 | - $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
|
| 42 | + $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $children = array(); |
@@ -49,36 +49,36 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | function getChildren($parent) { |
| 51 | 51 | |
| 52 | - $modx = evolutionCMS(); |
|
| 53 | - global $children; |
|
| 54 | - global $deltime; |
|
| 55 | - |
|
| 56 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
| 57 | - // the document has children documents, we'll need to delete those too |
|
| 58 | - while ($row=$modx->db->getRow($rs)) { |
|
| 59 | - $children[] = $row['id']; |
|
| 60 | - getChildren($row['id']); |
|
| 61 | - //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
|
| 62 | - } |
|
| 52 | + $modx = evolutionCMS(); |
|
| 53 | + global $children; |
|
| 54 | + global $deltime; |
|
| 55 | + |
|
| 56 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
| 57 | + // the document has children documents, we'll need to delete those too |
|
| 58 | + while ($row=$modx->db->getRow($rs)) { |
|
| 59 | + $children[] = $row['id']; |
|
| 60 | + getChildren($row['id']); |
|
| 61 | + //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | getChildren($id); |
| 66 | 66 | |
| 67 | 67 | if(count($children)>0) { |
| 68 | - $modx->db->update( |
|
| 69 | - array( |
|
| 70 | - 'deleted' => 0, |
|
| 71 | - 'deletedby' => 0, |
|
| 72 | - 'deletedon' => 0, |
|
| 73 | - ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")"); |
|
| 68 | + $modx->db->update( |
|
| 69 | + array( |
|
| 70 | + 'deleted' => 0, |
|
| 71 | + 'deletedby' => 0, |
|
| 72 | + 'deletedon' => 0, |
|
| 73 | + ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")"); |
|
| 74 | 74 | } |
| 75 | 75 | //'undelete' the document. |
| 76 | 76 | $modx->db->update( |
| 77 | - array( |
|
| 78 | - 'deleted' => 0, |
|
| 79 | - 'deletedby' => 0, |
|
| 80 | - 'deletedon' => 0, |
|
| 81 | - ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
| 77 | + array( |
|
| 78 | + 'deleted' => 0, |
|
| 79 | + 'deletedby' => 0, |
|
| 80 | + 'deletedon' => 0, |
|
| 81 | + ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
| 82 | 82 | |
| 83 | 83 | $modx->invokeEvent("OnDocFormUnDelete", |
| 84 | 84 | array( |
@@ -1,44 +1,44 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('delete_document')) { |
|
| 5 | +if (!$modx->hasPermission('delete_document')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /************ webber ********/ |
| 15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
| 15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
| 16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
| 17 | 17 | |
| 18 | 18 | /************** webber *************/ |
| 19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
| 20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
| 21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
| 22 | -$add_path=$sd.$sb.$pg; |
|
| 19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
| 20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
| 21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
| 22 | +$add_path = $sd.$sb.$pg; |
|
| 23 | 23 | |
| 24 | 24 | /***********************************/ |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | // check permissions on the document |
| 28 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
| 28 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
| 29 | 29 | $udperms = new udperms(); |
| 30 | 30 | $udperms->user = $modx->getLoginUserID(); |
| 31 | 31 | $udperms->document = $id; |
| 32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
| 33 | 33 | |
| 34 | -if(!$udperms->checkPermissions()) { |
|
| 34 | +if (!$udperms->checkPermissions()) { |
|
| 35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // get the timestamp on which the document was deleted. |
| 39 | 39 | $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1"); |
| 40 | 40 | $deltime = $modx->db->getValue($rs); |
| 41 | -if(!$deltime) { |
|
| 41 | +if (!$deltime) { |
|
| 42 | 42 | $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @param int $parent |
| 49 | 49 | */ |
| 50 | -function getChildren($parent) { |
|
| 50 | +function getChildren($parent){ |
|
| 51 | 51 | |
| 52 | 52 | $modx = evolutionCMS(); |
| 53 | 53 | global $children; |
| 54 | 54 | global $deltime; |
| 55 | 55 | |
| 56 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
| 56 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int) $parent."' AND deleted=1 AND deletedon='".(int) $deltime."'"); |
|
| 57 | 57 | // the document has children documents, we'll need to delete those too |
| 58 | - while ($row=$modx->db->getRow($rs)) { |
|
| 58 | + while ($row = $modx->db->getRow($rs)) { |
|
| 59 | 59 | $children[] = $row['id']; |
| 60 | 60 | getChildren($row['id']); |
| 61 | 61 | //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | getChildren($id); |
| 66 | 66 | |
| 67 | -if(count($children)>0) { |
|
| 67 | +if (count($children) > 0) { |
|
| 68 | 68 | $modx->db->update( |
| 69 | 69 | array( |
| 70 | 70 | 'deleted' => 0, |
@@ -93,5 +93,5 @@ discard block |
||
| 93 | 93 | $modx->clearCache('full'); |
| 94 | 94 | |
| 95 | 95 | // finished emptying cache - redirect |
| 96 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 96 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
| 97 | 97 | header($header); |
@@ -47,7 +47,8 @@ |
||
| 47 | 47 | /** |
| 48 | 48 | * @param int $parent |
| 49 | 49 | */ |
| 50 | -function getChildren($parent) { |
|
| 50 | +function getChildren($parent) |
|
| 51 | +{ |
|
| 51 | 52 | |
| 52 | 53 | $modx = evolutionCMS(); |
| 53 | 54 | global $children; |