@@ -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 | } |
@@ -1,21 +1,21 @@ 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 | switch((int) $modx->manager->action) { |
| 7 | - case 35: |
|
| 8 | - if(!$modx->hasPermission('edit_role')) { |
|
| 9 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | - } |
|
| 11 | - break; |
|
| 12 | - case 38: |
|
| 13 | - if(!$modx->hasPermission('new_role')) { |
|
| 14 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 15 | - } |
|
| 16 | - break; |
|
| 17 | - default: |
|
| 18 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | + case 35: |
|
| 8 | + if(!$modx->hasPermission('edit_role')) { |
|
| 9 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 10 | + } |
|
| 11 | + break; |
|
| 12 | + case 38: |
|
| 13 | + if(!$modx->hasPermission('new_role')) { |
|
| 14 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 15 | + } |
|
| 16 | + break; |
|
| 17 | + default: |
|
| 18 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $role = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | // check to see the snippet editor isn't locked |
| 26 | 26 | if($lockedEl = $modx->elementIsLocked(8, $role)) { |
| 27 | - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role'])); |
|
| 27 | + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role'])); |
|
| 28 | 28 | } |
| 29 | 29 | // end check for lock |
| 30 | 30 | |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | $modx->lockElement(8, $role); |
| 33 | 33 | |
| 34 | 34 | if($modx->manager->action == '35') { |
| 35 | - $rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'"); |
|
| 36 | - $roledata = $modx->db->getRow($rs); |
|
| 37 | - if(!$roledata) { |
|
| 38 | - $modx->webAlertAndQuit("No role returned!"); |
|
| 39 | - } |
|
| 40 | - $_SESSION['itemname'] = $roledata['name']; |
|
| 35 | + $rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'"); |
|
| 36 | + $roledata = $modx->db->getRow($rs); |
|
| 37 | + if(!$roledata) { |
|
| 38 | + $modx->webAlertAndQuit("No role returned!"); |
|
| 39 | + } |
|
| 40 | + $_SESSION['itemname'] = $roledata['name']; |
|
| 41 | 41 | } else { |
| 42 | - $roledata = 0; |
|
| 43 | - $_SESSION['itemname'] = $_lang["new_role"]; |
|
| 42 | + $roledata = 0; |
|
| 43 | + $_SESSION['itemname'] = $_lang["new_role"]; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // Add lock-element JS-Script |
@@ -107,63 +107,63 @@ discard block |
||
| 107 | 107 | <div class="form-group"> |
| 108 | 108 | <h3><?= $_lang['page_data_general'] ?></h3> |
| 109 | 109 | <?php |
| 110 | - echo render_form('frames', $_lang['role_frames'], 'disabled'); |
|
| 111 | - echo render_form('home', $_lang['role_home'], 'disabled'); |
|
| 112 | - echo render_form('messages', $_lang['role_messages']); |
|
| 113 | - echo render_form('logout', $_lang['role_logout'], 'disabled'); |
|
| 114 | - echo render_form('help', $_lang['role_help']); |
|
| 115 | - echo render_form('action_ok', $_lang['role_actionok'], 'disabled'); |
|
| 116 | - echo render_form('error_dialog', $_lang['role_errors'], 'disabled'); |
|
| 117 | - echo render_form('about', $_lang['role_about'], 'disabled'); |
|
| 118 | - echo render_form('credits', $_lang['role_credits'], 'disabled'); |
|
| 119 | - echo render_form('change_password', $_lang['role_change_password']); |
|
| 120 | - echo render_form('save_password', $_lang['role_save_password']); |
|
| 121 | - ?> |
|
| 110 | + echo render_form('frames', $_lang['role_frames'], 'disabled'); |
|
| 111 | + echo render_form('home', $_lang['role_home'], 'disabled'); |
|
| 112 | + echo render_form('messages', $_lang['role_messages']); |
|
| 113 | + echo render_form('logout', $_lang['role_logout'], 'disabled'); |
|
| 114 | + echo render_form('help', $_lang['role_help']); |
|
| 115 | + echo render_form('action_ok', $_lang['role_actionok'], 'disabled'); |
|
| 116 | + echo render_form('error_dialog', $_lang['role_errors'], 'disabled'); |
|
| 117 | + echo render_form('about', $_lang['role_about'], 'disabled'); |
|
| 118 | + echo render_form('credits', $_lang['role_credits'], 'disabled'); |
|
| 119 | + echo render_form('change_password', $_lang['role_change_password']); |
|
| 120 | + echo render_form('save_password', $_lang['role_save_password']); |
|
| 121 | + ?> |
|
| 122 | 122 | </div> |
| 123 | 123 | </div> |
| 124 | 124 | <div class="col-sm-6 col-lg-3"> |
| 125 | 125 | <div class="form-group"> |
| 126 | 126 | <h3><?= $_lang['role_content_management'] ?></h3> |
| 127 | 127 | <?php |
| 128 | - echo render_form('view_document', $_lang['role_view_docdata'], 'disabled'); |
|
| 129 | - echo render_form('new_document', $_lang['role_create_doc']); |
|
| 130 | - echo render_form('edit_document', $_lang['role_edit_doc']); |
|
| 131 | - echo render_form('change_resourcetype', $_lang['role_change_resourcetype']); |
|
| 132 | - echo render_form('save_document', $_lang['role_save_doc']); |
|
| 133 | - echo render_form('publish_document', $_lang['role_publish_doc']); |
|
| 134 | - echo render_form('delete_document', $_lang['role_delete_doc']); |
|
| 135 | - echo render_form('empty_trash', $_lang['role_empty_trash']); |
|
| 136 | - echo render_form('empty_cache', $_lang['role_cache_refresh']); |
|
| 137 | - echo render_form('view_unpublished', $_lang['role_view_unpublished']); |
|
| 138 | - ?> |
|
| 128 | + echo render_form('view_document', $_lang['role_view_docdata'], 'disabled'); |
|
| 129 | + echo render_form('new_document', $_lang['role_create_doc']); |
|
| 130 | + echo render_form('edit_document', $_lang['role_edit_doc']); |
|
| 131 | + echo render_form('change_resourcetype', $_lang['role_change_resourcetype']); |
|
| 132 | + echo render_form('save_document', $_lang['role_save_doc']); |
|
| 133 | + echo render_form('publish_document', $_lang['role_publish_doc']); |
|
| 134 | + echo render_form('delete_document', $_lang['role_delete_doc']); |
|
| 135 | + echo render_form('empty_trash', $_lang['role_empty_trash']); |
|
| 136 | + echo render_form('empty_cache', $_lang['role_cache_refresh']); |
|
| 137 | + echo render_form('view_unpublished', $_lang['role_view_unpublished']); |
|
| 138 | + ?> |
|
| 139 | 139 | </div> |
| 140 | 140 | </div> |
| 141 | 141 | <div class="col-sm-6 col-lg-3 form-group"> |
| 142 | 142 | <div class="form-group"> |
| 143 | 143 | <h3><?= $_lang['role_file_management'] ?></h3> |
| 144 | 144 | <?php |
| 145 | - echo render_form('file_manager', $_lang['role_file_manager']); |
|
| 146 | - echo render_form('assets_files', $_lang['role_assets_files']); |
|
| 147 | - echo render_form('assets_images', $_lang['role_assets_images']); |
|
| 148 | - ?> |
|
| 145 | + echo render_form('file_manager', $_lang['role_file_manager']); |
|
| 146 | + echo render_form('assets_files', $_lang['role_assets_files']); |
|
| 147 | + echo render_form('assets_images', $_lang['role_assets_images']); |
|
| 148 | + ?> |
|
| 149 | 149 | </div> |
| 150 | 150 | <div class="form-group"> |
| 151 | 151 | <h3><?= $_lang['category_management'] ?></h3> |
| 152 | 152 | <?php |
| 153 | - echo render_form('category_manager', $_lang['role_category_manager']); |
|
| 154 | - ?> |
|
| 153 | + echo render_form('category_manager', $_lang['role_category_manager']); |
|
| 154 | + ?> |
|
| 155 | 155 | </div> |
| 156 | 156 | </div> |
| 157 | 157 | <div class="col-sm-6 col-lg-3"> |
| 158 | 158 | <div class="form-group"> |
| 159 | 159 | <h3><?= $_lang['role_module_management'] ?></h3> |
| 160 | 160 | <?php |
| 161 | - echo render_form('new_module', $_lang['role_new_module']); |
|
| 162 | - echo render_form('edit_module', $_lang['role_edit_module']); |
|
| 163 | - echo render_form('save_module', $_lang['role_save_module']); |
|
| 164 | - echo render_form('delete_module', $_lang['role_delete_module']); |
|
| 165 | - echo render_form('exec_module', $_lang['role_run_module']); |
|
| 166 | - ?> |
|
| 161 | + echo render_form('new_module', $_lang['role_new_module']); |
|
| 162 | + echo render_form('edit_module', $_lang['role_edit_module']); |
|
| 163 | + echo render_form('save_module', $_lang['role_save_module']); |
|
| 164 | + echo render_form('delete_module', $_lang['role_delete_module']); |
|
| 165 | + echo render_form('exec_module', $_lang['role_run_module']); |
|
| 166 | + ?> |
|
| 167 | 167 | </div> |
| 168 | 168 | </div> |
| 169 | 169 | </div> |
@@ -173,44 +173,44 @@ discard block |
||
| 173 | 173 | <div class="form-group"> |
| 174 | 174 | <h3><?= $_lang['role_template_management'] ?></h3> |
| 175 | 175 | <?php |
| 176 | - echo render_form('new_template', $_lang['role_create_template']); |
|
| 177 | - echo render_form('edit_template', $_lang['role_edit_template']); |
|
| 178 | - echo render_form('save_template', $_lang['role_save_template']); |
|
| 179 | - echo render_form('delete_template', $_lang['role_delete_template']); |
|
| 180 | - ?> |
|
| 176 | + echo render_form('new_template', $_lang['role_create_template']); |
|
| 177 | + echo render_form('edit_template', $_lang['role_edit_template']); |
|
| 178 | + echo render_form('save_template', $_lang['role_save_template']); |
|
| 179 | + echo render_form('delete_template', $_lang['role_delete_template']); |
|
| 180 | + ?> |
|
| 181 | 181 | </div> |
| 182 | 182 | </div> |
| 183 | 183 | <div class="col-sm-6 col-lg-3"> |
| 184 | 184 | <div class="form-group"> |
| 185 | 185 | <h3><?= $_lang['role_snippet_management'] ?></h3> |
| 186 | 186 | <?php |
| 187 | - echo render_form('new_snippet', $_lang['role_create_snippet']); |
|
| 188 | - echo render_form('edit_snippet', $_lang['role_edit_snippet']); |
|
| 189 | - echo render_form('save_snippet', $_lang['role_save_snippet']); |
|
| 190 | - echo render_form('delete_snippet', $_lang['role_delete_snippet']); |
|
| 191 | - ?> |
|
| 187 | + echo render_form('new_snippet', $_lang['role_create_snippet']); |
|
| 188 | + echo render_form('edit_snippet', $_lang['role_edit_snippet']); |
|
| 189 | + echo render_form('save_snippet', $_lang['role_save_snippet']); |
|
| 190 | + echo render_form('delete_snippet', $_lang['role_delete_snippet']); |
|
| 191 | + ?> |
|
| 192 | 192 | </div> |
| 193 | 193 | </div> |
| 194 | 194 | <div class="col-sm-6 col-lg-3"> |
| 195 | 195 | <div class="form-group"> |
| 196 | 196 | <h3><?= $_lang['role_chunk_management'] ?></h3> |
| 197 | 197 | <?php |
| 198 | - echo render_form('new_chunk', $_lang['role_create_chunk']); |
|
| 199 | - echo render_form('edit_chunk', $_lang['role_edit_chunk']); |
|
| 200 | - echo render_form('save_chunk', $_lang['role_save_chunk']); |
|
| 201 | - echo render_form('delete_chunk', $_lang['role_delete_chunk']); |
|
| 202 | - ?> |
|
| 198 | + echo render_form('new_chunk', $_lang['role_create_chunk']); |
|
| 199 | + echo render_form('edit_chunk', $_lang['role_edit_chunk']); |
|
| 200 | + echo render_form('save_chunk', $_lang['role_save_chunk']); |
|
| 201 | + echo render_form('delete_chunk', $_lang['role_delete_chunk']); |
|
| 202 | + ?> |
|
| 203 | 203 | </div> |
| 204 | 204 | </div> |
| 205 | 205 | <div class="col-sm-6 col-lg-3"> |
| 206 | 206 | <div class="form-group"> |
| 207 | 207 | <h3><?= $_lang['role_plugin_management'] ?></h3> |
| 208 | 208 | <?php |
| 209 | - echo render_form('new_plugin', $_lang['role_create_plugin']); |
|
| 210 | - echo render_form('edit_plugin', $_lang['role_edit_plugin']); |
|
| 211 | - echo render_form('save_plugin', $_lang['role_save_plugin']); |
|
| 212 | - echo render_form('delete_plugin', $_lang['role_delete_plugin']); |
|
| 213 | - ?> |
|
| 209 | + echo render_form('new_plugin', $_lang['role_create_plugin']); |
|
| 210 | + echo render_form('edit_plugin', $_lang['role_edit_plugin']); |
|
| 211 | + echo render_form('save_plugin', $_lang['role_save_plugin']); |
|
| 212 | + echo render_form('delete_plugin', $_lang['role_delete_plugin']); |
|
| 213 | + ?> |
|
| 214 | 214 | </div> |
| 215 | 215 | </div> |
| 216 | 216 | </div> |
@@ -220,42 +220,42 @@ discard block |
||
| 220 | 220 | <div class="form-group"> |
| 221 | 221 | <h3><?= $_lang['role_user_management'] ?></h3> |
| 222 | 222 | <?php |
| 223 | - echo render_form('new_user', $_lang['role_new_user']); |
|
| 224 | - echo render_form('edit_user', $_lang['role_edit_user']); |
|
| 225 | - echo render_form('save_user', $_lang['role_save_user']); |
|
| 226 | - echo render_form('delete_user', $_lang['role_delete_user']); |
|
| 227 | - ?> |
|
| 223 | + echo render_form('new_user', $_lang['role_new_user']); |
|
| 224 | + echo render_form('edit_user', $_lang['role_edit_user']); |
|
| 225 | + echo render_form('save_user', $_lang['role_save_user']); |
|
| 226 | + echo render_form('delete_user', $_lang['role_delete_user']); |
|
| 227 | + ?> |
|
| 228 | 228 | </div> |
| 229 | 229 | </div> |
| 230 | 230 | <div class="col-sm-6 col-lg-3"> |
| 231 | 231 | <div class="form-group"> |
| 232 | 232 | <h3><?= $_lang['role_web_user_management'] ?></h3> |
| 233 | 233 | <?php |
| 234 | - echo render_form('new_web_user', $_lang['role_new_web_user']); |
|
| 235 | - echo render_form('edit_web_user', $_lang['role_edit_web_user']); |
|
| 236 | - echo render_form('save_web_user', $_lang['role_save_web_user']); |
|
| 237 | - echo render_form('delete_web_user', $_lang['role_delete_web_user']); |
|
| 238 | - ?> |
|
| 234 | + echo render_form('new_web_user', $_lang['role_new_web_user']); |
|
| 235 | + echo render_form('edit_web_user', $_lang['role_edit_web_user']); |
|
| 236 | + echo render_form('save_web_user', $_lang['role_save_web_user']); |
|
| 237 | + echo render_form('delete_web_user', $_lang['role_delete_web_user']); |
|
| 238 | + ?> |
|
| 239 | 239 | </div> |
| 240 | 240 | </div> |
| 241 | 241 | <div class="col-sm-6 col-lg-3"> |
| 242 | 242 | <div class="form-group"> |
| 243 | 243 | <h3><?= $_lang['role_udperms'] ?></h3> |
| 244 | 244 | <?php |
| 245 | - echo render_form('access_permissions', $_lang['role_access_persmissions']); |
|
| 246 | - echo render_form('web_access_permissions', $_lang['role_web_access_persmissions']); |
|
| 247 | - ?> |
|
| 245 | + echo render_form('access_permissions', $_lang['role_access_persmissions']); |
|
| 246 | + echo render_form('web_access_permissions', $_lang['role_web_access_persmissions']); |
|
| 247 | + ?> |
|
| 248 | 248 | </div> |
| 249 | 249 | </div> |
| 250 | 250 | <div class="col-sm-6 col-lg-3"> |
| 251 | 251 | <div class="form-group"> |
| 252 | 252 | <h3><?= $_lang['role_role_management'] ?></h3> |
| 253 | 253 | <?php |
| 254 | - echo render_form('new_role', $_lang['role_new_role']); |
|
| 255 | - echo render_form('edit_role', $_lang['role_edit_role']); |
|
| 256 | - echo render_form('save_role', $_lang['role_save_role']); |
|
| 257 | - echo render_form('delete_role', $_lang['role_delete_role']); |
|
| 258 | - ?> |
|
| 254 | + echo render_form('new_role', $_lang['role_new_role']); |
|
| 255 | + echo render_form('edit_role', $_lang['role_edit_role']); |
|
| 256 | + echo render_form('save_role', $_lang['role_save_role']); |
|
| 257 | + echo render_form('delete_role', $_lang['role_delete_role']); |
|
| 258 | + ?> |
|
| 259 | 259 | </div> |
| 260 | 260 | </div> |
| 261 | 261 | </div> |
@@ -265,23 +265,23 @@ discard block |
||
| 265 | 265 | <div class="form-group"> |
| 266 | 266 | <h3><?= $_lang['role_eventlog_management'] ?></h3> |
| 267 | 267 | <?php |
| 268 | - echo render_form('view_eventlog', $_lang['role_view_eventlog']); |
|
| 269 | - echo render_form('delete_eventlog', $_lang['role_delete_eventlog']); |
|
| 270 | - ?> |
|
| 268 | + echo render_form('view_eventlog', $_lang['role_view_eventlog']); |
|
| 269 | + echo render_form('delete_eventlog', $_lang['role_delete_eventlog']); |
|
| 270 | + ?> |
|
| 271 | 271 | </div> |
| 272 | 272 | </div> |
| 273 | 273 | <div class="col-sm-6 col-lg-3"> |
| 274 | 274 | <div class="form-group"> |
| 275 | 275 | <h3><?= $_lang['role_config_management'] ?></h3> |
| 276 | 276 | <?php |
| 277 | - echo render_form('logs', $_lang['role_view_logs']); |
|
| 278 | - echo render_form('settings', $_lang['role_edit_settings']); |
|
| 279 | - echo render_form('bk_manager', $_lang['role_bk_manager']); |
|
| 280 | - echo render_form('import_static', $_lang['role_import_static']); |
|
| 281 | - echo render_form('export_static', $_lang['role_export_static']); |
|
| 282 | - echo render_form('remove_locks', $_lang['role_remove_locks']); |
|
| 283 | - echo render_form('display_locks', $_lang['role_display_locks']); |
|
| 284 | - ?> |
|
| 277 | + echo render_form('logs', $_lang['role_view_logs']); |
|
| 278 | + echo render_form('settings', $_lang['role_edit_settings']); |
|
| 279 | + echo render_form('bk_manager', $_lang['role_bk_manager']); |
|
| 280 | + echo render_form('import_static', $_lang['role_import_static']); |
|
| 281 | + echo render_form('export_static', $_lang['role_export_static']); |
|
| 282 | + echo render_form('remove_locks', $_lang['role_remove_locks']); |
|
| 283 | + echo render_form('display_locks', $_lang['role_display_locks']); |
|
| 284 | + ?> |
|
| 285 | 285 | </div> |
| 286 | 286 | </div> |
| 287 | 287 | </div> |
@@ -300,32 +300,32 @@ discard block |
||
| 300 | 300 | * @return string |
| 301 | 301 | */ |
| 302 | 302 | function render_form($name, $label, $status = '') { |
| 303 | - $modx = evolutionCMS(); global $roledata; |
|
| 303 | + $modx = evolutionCMS(); global $roledata; |
|
| 304 | 304 | |
| 305 | - $tpl = '<label class="d-block" for="[+name+]check"> |
|
| 305 | + $tpl = '<label class="d-block" for="[+name+]check"> |
|
| 306 | 306 | <input name="[+name+]check" id="[+name+]check" class="click" type="checkbox" onchange="changestate(document.userform.[+name+])" [+checked+] [+status+]> |
| 307 | 307 | <input type="hidden" class="[+set+]" name="[+name+]" value="[+value+]"> |
| 308 | 308 | [+label+] |
| 309 | 309 | </label>'; |
| 310 | 310 | |
| 311 | - $checked = ($roledata[$name] == 1) ? 'checked' : ''; |
|
| 312 | - $value = ($roledata[$name] == 1) ? 1 : 0; |
|
| 313 | - if($status == 'disabled') { |
|
| 314 | - $checked = 'checked'; |
|
| 315 | - $value = 1; |
|
| 316 | - $set = 'fix'; |
|
| 317 | - } else { |
|
| 318 | - $set = 'set'; |
|
| 319 | - } |
|
| 311 | + $checked = ($roledata[$name] == 1) ? 'checked' : ''; |
|
| 312 | + $value = ($roledata[$name] == 1) ? 1 : 0; |
|
| 313 | + if($status == 'disabled') { |
|
| 314 | + $checked = 'checked'; |
|
| 315 | + $value = 1; |
|
| 316 | + $set = 'fix'; |
|
| 317 | + } else { |
|
| 318 | + $set = 'set'; |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - $ph = array( |
|
| 322 | - 'name' => $name, |
|
| 323 | - 'checked' => $checked, |
|
| 324 | - 'status' => $status, |
|
| 325 | - 'value' => $value, |
|
| 326 | - 'label' => $label, |
|
| 327 | - 'set' => $set |
|
| 328 | - ); |
|
| 321 | + $ph = array( |
|
| 322 | + 'name' => $name, |
|
| 323 | + 'checked' => $checked, |
|
| 324 | + 'status' => $status, |
|
| 325 | + 'value' => $value, |
|
| 326 | + 'label' => $label, |
|
| 327 | + 'set' => $set |
|
| 328 | + ); |
|
| 329 | 329 | |
| 330 | - return $modx->parseText($tpl, $ph); |
|
| 330 | + return $modx->parseText($tpl, $ph); |
|
| 331 | 331 | } |
@@ -1,16 +1,16 @@ 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 | -switch((int) $modx->manager->action) { |
|
| 6 | +switch ((int) $modx->manager->action) { |
|
| 7 | 7 | case 35: |
| 8 | - if(!$modx->hasPermission('edit_role')) { |
|
| 8 | + if (!$modx->hasPermission('edit_role')) { |
|
| 9 | 9 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 10 | 10 | } |
| 11 | 11 | break; |
| 12 | 12 | case 38: |
| 13 | - if(!$modx->hasPermission('new_role')) { |
|
| 13 | + if (!$modx->hasPermission('new_role')) { |
|
| 14 | 14 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 15 | 15 | } |
| 16 | 16 | break; |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -$role = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 21 | +$role = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
| 22 | 22 | |
| 23 | 23 | $tbl_user_roles = $modx->getFullTableName('user_roles'); |
| 24 | 24 | |
| 25 | 25 | // check to see the snippet editor isn't locked |
| 26 | -if($lockedEl = $modx->elementIsLocked(8, $role)) { |
|
| 26 | +if ($lockedEl = $modx->elementIsLocked(8, $role)) { |
|
| 27 | 27 | $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['role'])); |
| 28 | 28 | } |
| 29 | 29 | // end check for lock |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | // Lock snippet for other users to edit |
| 32 | 32 | $modx->lockElement(8, $role); |
| 33 | 33 | |
| 34 | -if($modx->manager->action == '35') { |
|
| 34 | +if ($modx->manager->action == '35') { |
|
| 35 | 35 | $rs = $modx->db->select('*', $tbl_user_roles, "id='{$role}'"); |
| 36 | 36 | $roledata = $modx->db->getRow($rs); |
| 37 | - if(!$roledata) { |
|
| 37 | + if (!$roledata) { |
|
| 38 | 38 | $modx->webAlertAndQuit("No role returned!"); |
| 39 | 39 | } |
| 40 | 40 | $_SESSION['itemname'] = $roledata['name']; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // Add lock-element JS-Script |
| 47 | 47 | $lockElementId = $role; |
| 48 | 48 | $lockElementType = 8; |
| 49 | -require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); |
|
| 49 | +require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php'); |
|
| 50 | 50 | ?> |
| 51 | 51 | <script type="text/javascript"> |
| 52 | 52 | function changestate(element) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | <input type="hidden" name="id" value="<?= $_GET['id'] ?>"> |
| 83 | 83 | |
| 84 | 84 | <h1> |
| 85 | - <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'] . '<small>(' . $roledata['id'] . ')</small>' : $_lang['role_title']) ?> |
|
| 85 | + <i class="fa fa-legal"></i><?= ($roledata['name'] ? $roledata['name'].'<small>('.$roledata['id'].')</small>' : $_lang['role_title']) ?> |
|
| 86 | 86 | </h1> |
| 87 | 87 | |
| 88 | 88 | <?= $_style['actionbuttons']['dynamic']['savedelete'] ?> |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @param string $status |
| 300 | 300 | * @return string |
| 301 | 301 | */ |
| 302 | -function render_form($name, $label, $status = '') { |
|
| 302 | +function render_form($name, $label, $status = ''){ |
|
| 303 | 303 | $modx = evolutionCMS(); global $roledata; |
| 304 | 304 | |
| 305 | 305 | $tpl = '<label class="d-block" for="[+name+]check"> |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | $checked = ($roledata[$name] == 1) ? 'checked' : ''; |
| 312 | 312 | $value = ($roledata[$name] == 1) ? 1 : 0; |
| 313 | - if($status == 'disabled') { |
|
| 313 | + if ($status == 'disabled') { |
|
| 314 | 314 | $checked = 'checked'; |
| 315 | 315 | $value = 1; |
| 316 | 316 | $set = 'fix'; |
@@ -299,7 +299,8 @@ |
||
| 299 | 299 | * @param string $status |
| 300 | 300 | * @return string |
| 301 | 301 | */ |
| 302 | -function render_form($name, $label, $status = '') { |
|
| 302 | +function render_form($name, $label, $status = '') |
|
| 303 | +{ |
|
| 303 | 304 | $modx = evolutionCMS(); global $roledata; |
| 304 | 305 | |
| 305 | 306 | $tpl = '<label class="d-block" for="[+name+]check"> |
@@ -893,7 +893,9 @@ |
||
| 893 | 893 | $modx = evolutionCMS(); global $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; |
| 894 | 894 | $msg = ''; |
| 895 | 895 | foreach ($_FILES['userfile']['name'] as $i => $name) { |
| 896 | - if (empty($_FILES['userfile']['tmp_name'][$i])) continue; |
|
| 896 | + if (empty($_FILES['userfile']['tmp_name'][$i])) { |
|
| 897 | + continue; |
|
| 898 | + } |
|
| 897 | 899 | $userfile= array(); |
| 898 | 900 | |
| 899 | 901 | $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; |
@@ -14,158 +14,158 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
| 16 | 16 | $modx = evolutionCMS(); |
| 17 | - global $_style; |
|
| 18 | - global $_lang; |
|
| 19 | - global $content; |
|
| 20 | - global $which_browser; |
|
| 17 | + global $_style; |
|
| 18 | + global $_lang; |
|
| 19 | + global $content; |
|
| 20 | + global $which_browser; |
|
| 21 | 21 | |
| 22 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
| 23 | - $eval_str = trim(substr($default_text, 7)); |
|
| 24 | - $default_text = eval($eval_str); |
|
| 25 | - $field_value = $default_text; |
|
| 26 | - } |
|
| 22 | + if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
| 23 | + $eval_str = trim(substr($default_text, 7)); |
|
| 24 | + $default_text = eval($eval_str); |
|
| 25 | + $field_value = $default_text; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $field_html = ''; |
|
| 29 | - $cimode = strpos($field_type, ':'); |
|
| 30 | - if($cimode === false) { |
|
| 31 | - switch($field_type) { |
|
| 28 | + $field_html = ''; |
|
| 29 | + $cimode = strpos($field_type, ':'); |
|
| 30 | + if($cimode === false) { |
|
| 31 | + switch($field_type) { |
|
| 32 | 32 | |
| 33 | - case "text": // handler for regular text boxes |
|
| 34 | - case "rawtext"; // non-htmlentity converted text boxes |
|
| 35 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
| 36 | - break; |
|
| 37 | - case "email": // handles email input fields |
|
| 38 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
| 39 | - break; |
|
| 40 | - case "number": // handles the input of numbers |
|
| 41 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
| 42 | - break; |
|
| 43 | - case "textareamini": // handler for textarea mini boxes |
|
| 44 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 45 | - break; |
|
| 46 | - case "textarea": // handler for textarea boxes |
|
| 47 | - case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
| 48 | - case "htmlarea": // handler for textarea boxes (deprecated) |
|
| 49 | - case "richtext": // handler for textarea boxes |
|
| 50 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 51 | - break; |
|
| 52 | - case "date": |
|
| 53 | - $field_id = str_replace(array( |
|
| 54 | - '-', |
|
| 55 | - '.' |
|
| 56 | - ), '_', urldecode($field_id)); |
|
| 57 | - if($field_value == '') { |
|
| 58 | - $field_value = 0; |
|
| 59 | - } |
|
| 60 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
| 61 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
| 33 | + case "text": // handler for regular text boxes |
|
| 34 | + case "rawtext"; // non-htmlentity converted text boxes |
|
| 35 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
| 36 | + break; |
|
| 37 | + case "email": // handles email input fields |
|
| 38 | + $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
| 39 | + break; |
|
| 40 | + case "number": // handles the input of numbers |
|
| 41 | + $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
| 42 | + break; |
|
| 43 | + case "textareamini": // handler for textarea mini boxes |
|
| 44 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 45 | + break; |
|
| 46 | + case "textarea": // handler for textarea boxes |
|
| 47 | + case "rawtextarea": // non-htmlentity convertex textarea boxes |
|
| 48 | + case "htmlarea": // handler for textarea boxes (deprecated) |
|
| 49 | + case "richtext": // handler for textarea boxes |
|
| 50 | + $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 51 | + break; |
|
| 52 | + case "date": |
|
| 53 | + $field_id = str_replace(array( |
|
| 54 | + '-', |
|
| 55 | + '.' |
|
| 56 | + ), '_', urldecode($field_id)); |
|
| 57 | + if($field_value == '') { |
|
| 58 | + $field_value = 0; |
|
| 59 | + } |
|
| 60 | + $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
| 61 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
| 62 | 62 | |
| 63 | - break; |
|
| 64 | - case "dropdown": // handler for select boxes |
|
| 65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
| 66 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 68 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 69 | - if(strlen($itemvalue) == 0) { |
|
| 70 | - $itemvalue = $item; |
|
| 71 | - } |
|
| 72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 73 | - } |
|
| 74 | - $field_html .= "</select>"; |
|
| 75 | - break; |
|
| 76 | - case "listbox": // handler for select boxes |
|
| 77 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
| 78 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 79 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 80 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 81 | - if(strlen($itemvalue) == 0) { |
|
| 82 | - $itemvalue = $item; |
|
| 83 | - } |
|
| 84 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 85 | - } |
|
| 86 | - $field_html .= "</select>"; |
|
| 87 | - break; |
|
| 88 | - case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
| 89 | - $field_value = explode("||", $field_value); |
|
| 90 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
| 91 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 92 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 93 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 94 | - if(strlen($itemvalue) == 0) { |
|
| 95 | - $itemvalue = $item; |
|
| 96 | - } |
|
| 97 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 98 | - } |
|
| 99 | - $field_html .= "</select>"; |
|
| 100 | - break; |
|
| 101 | - case "url": // handles url input fields |
|
| 102 | - $urls = array( |
|
| 103 | - '' => '--', |
|
| 104 | - 'http://' => 'http://', |
|
| 105 | - 'https://' => 'https://', |
|
| 106 | - 'ftp://' => 'ftp://', |
|
| 107 | - 'mailto:' => 'mailto:' |
|
| 108 | - ); |
|
| 109 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
| 110 | - foreach($urls as $k => $v) { |
|
| 111 | - if(strpos($field_value, $v) === false) { |
|
| 112 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
| 113 | - } else { |
|
| 114 | - $field_value = str_replace($v, '', $field_value); |
|
| 115 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - $field_html .= '</select></td><td>'; |
|
| 119 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
| 120 | - break; |
|
| 121 | - case 'checkbox': // handles check boxes |
|
| 122 | - $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
| 123 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 124 | - $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
| 125 | - static $i = 0; |
|
| 126 | - $_ = array(); |
|
| 127 | - foreach($index_list as $c => $item) { |
|
| 128 | - if(is_array($item)) { |
|
| 129 | - $name = trim($item[0]); |
|
| 130 | - $value = isset($item[1]) ? $item[1] : $name; |
|
| 131 | - } else { |
|
| 132 | - $item = trim($item); |
|
| 133 | - list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
| 134 | - $item, |
|
| 135 | - $item |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
| 139 | - $param = array( |
|
| 140 | - $modx->htmlspecialchars($value), |
|
| 141 | - $i, |
|
| 142 | - $field_id, |
|
| 143 | - $checked, |
|
| 144 | - $modx->htmlspecialchars($name) |
|
| 145 | - ); |
|
| 146 | - $_[] = vsprintf($tpl, $param); |
|
| 147 | - $i++; |
|
| 148 | - } |
|
| 149 | - $field_html = implode("\n", $_); |
|
| 150 | - break; |
|
| 151 | - case "option": // handles radio buttons |
|
| 152 | - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 153 | - static $i = 0; |
|
| 154 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 155 | - list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 156 | - if(strlen($itemvalue) == 0) { |
|
| 157 | - $itemvalue = $item; |
|
| 158 | - } |
|
| 159 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
| 160 | - $i++; |
|
| 161 | - } |
|
| 162 | - break; |
|
| 163 | - case "image": // handles image fields using htmlarea image manager |
|
| 164 | - global $_lang; |
|
| 165 | - global $ResourceManagerLoaded; |
|
| 166 | - global $content, $use_editor, $which_editor; |
|
| 167 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 168 | - $field_html .= " |
|
| 63 | + break; |
|
| 64 | + case "dropdown": // handler for select boxes |
|
| 65 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
| 66 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 67 | + while(list($item, $itemvalue) = each($index_list)) { |
|
| 68 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 69 | + if(strlen($itemvalue) == 0) { |
|
| 70 | + $itemvalue = $item; |
|
| 71 | + } |
|
| 72 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 73 | + } |
|
| 74 | + $field_html .= "</select>"; |
|
| 75 | + break; |
|
| 76 | + case "listbox": // handler for select boxes |
|
| 77 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
| 78 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 79 | + while(list($item, $itemvalue) = each($index_list)) { |
|
| 80 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 81 | + if(strlen($itemvalue) == 0) { |
|
| 82 | + $itemvalue = $item; |
|
| 83 | + } |
|
| 84 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 85 | + } |
|
| 86 | + $field_html .= "</select>"; |
|
| 87 | + break; |
|
| 88 | + case "listbox-multiple": // handler for select boxes where you can choose multiple items |
|
| 89 | + $field_value = explode("||", $field_value); |
|
| 90 | + $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
| 91 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 92 | + while(list($item, $itemvalue) = each($index_list)) { |
|
| 93 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 94 | + if(strlen($itemvalue) == 0) { |
|
| 95 | + $itemvalue = $item; |
|
| 96 | + } |
|
| 97 | + $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 98 | + } |
|
| 99 | + $field_html .= "</select>"; |
|
| 100 | + break; |
|
| 101 | + case "url": // handles url input fields |
|
| 102 | + $urls = array( |
|
| 103 | + '' => '--', |
|
| 104 | + 'http://' => 'http://', |
|
| 105 | + 'https://' => 'https://', |
|
| 106 | + 'ftp://' => 'ftp://', |
|
| 107 | + 'mailto:' => 'mailto:' |
|
| 108 | + ); |
|
| 109 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
| 110 | + foreach($urls as $k => $v) { |
|
| 111 | + if(strpos($field_value, $v) === false) { |
|
| 112 | + $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
| 113 | + } else { |
|
| 114 | + $field_value = str_replace($v, '', $field_value); |
|
| 115 | + $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + $field_html .= '</select></td><td>'; |
|
| 119 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
| 120 | + break; |
|
| 121 | + case 'checkbox': // handles check boxes |
|
| 122 | + $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
|
| 123 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 124 | + $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
|
| 125 | + static $i = 0; |
|
| 126 | + $_ = array(); |
|
| 127 | + foreach($index_list as $c => $item) { |
|
| 128 | + if(is_array($item)) { |
|
| 129 | + $name = trim($item[0]); |
|
| 130 | + $value = isset($item[1]) ? $item[1] : $name; |
|
| 131 | + } else { |
|
| 132 | + $item = trim($item); |
|
| 133 | + list($name, $value) = (strpos($item, '==') !== false) ? explode('==', $item, 2) : array( |
|
| 134 | + $item, |
|
| 135 | + $item |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + $checked = in_array($value, $values) ? ' checked="checked"' : ''; |
|
| 139 | + $param = array( |
|
| 140 | + $modx->htmlspecialchars($value), |
|
| 141 | + $i, |
|
| 142 | + $field_id, |
|
| 143 | + $checked, |
|
| 144 | + $modx->htmlspecialchars($name) |
|
| 145 | + ); |
|
| 146 | + $_[] = vsprintf($tpl, $param); |
|
| 147 | + $i++; |
|
| 148 | + } |
|
| 149 | + $field_html = implode("\n", $_); |
|
| 150 | + break; |
|
| 151 | + case "option": // handles radio buttons |
|
| 152 | + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
|
| 153 | + static $i = 0; |
|
| 154 | + while(list($item, $itemvalue) = each($index_list)) { |
|
| 155 | + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
|
| 156 | + if(strlen($itemvalue) == 0) { |
|
| 157 | + $itemvalue = $item; |
|
| 158 | + } |
|
| 159 | + $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
| 160 | + $i++; |
|
| 161 | + } |
|
| 162 | + break; |
|
| 163 | + case "image": // handles image fields using htmlarea image manager |
|
| 164 | + global $_lang; |
|
| 165 | + global $ResourceManagerLoaded; |
|
| 166 | + global $content, $use_editor, $which_editor; |
|
| 167 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 168 | + $field_html .= " |
|
| 169 | 169 | <script type=\"text/javascript\"> |
| 170 | 170 | /* <![CDATA[ */ |
| 171 | 171 | var lastImageCtrl; |
@@ -224,18 +224,18 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | /* ]]> */ |
| 226 | 226 | </script>"; |
| 227 | - $ResourceManagerLoaded = true; |
|
| 228 | - } |
|
| 229 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
| 230 | - break; |
|
| 231 | - case "file": // handles the input of file uploads |
|
| 232 | - /* Modified by Timon for use with resource browser */ |
|
| 233 | - global $_lang; |
|
| 234 | - global $ResourceManagerLoaded; |
|
| 235 | - global $content, $use_editor, $which_editor; |
|
| 236 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 237 | - /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
| 238 | - $field_html .= " |
|
| 227 | + $ResourceManagerLoaded = true; |
|
| 228 | + } |
|
| 229 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
| 230 | + break; |
|
| 231 | + case "file": // handles the input of file uploads |
|
| 232 | + /* Modified by Timon for use with resource browser */ |
|
| 233 | + global $_lang; |
|
| 234 | + global $ResourceManagerLoaded; |
|
| 235 | + global $content, $use_editor, $which_editor; |
|
| 236 | + if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 237 | + /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
|
| 238 | + $field_html .= " |
|
| 239 | 239 | <script type=\"text/javascript\"> |
| 240 | 240 | /* <![CDATA[ */ |
| 241 | 241 | var lastImageCtrl; |
@@ -294,90 +294,90 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | /* ]]> */ |
| 296 | 296 | </script>"; |
| 297 | - $ResourceManagerLoaded = true; |
|
| 298 | - } |
|
| 299 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
| 297 | + $ResourceManagerLoaded = true; |
|
| 298 | + } |
|
| 299 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
| 300 | 300 | |
| 301 | - break; |
|
| 301 | + break; |
|
| 302 | 302 | |
| 303 | - case 'custom_tv': |
|
| 304 | - $custom_output = ''; |
|
| 305 | - /* If we are loading a file */ |
|
| 306 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
| 307 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
| 308 | - if(!file_exists($file_name)) { |
|
| 309 | - $custom_output = $file_name . ' does not exist'; |
|
| 310 | - } else { |
|
| 311 | - $custom_output = file_get_contents($file_name); |
|
| 312 | - } |
|
| 313 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
| 314 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
| 315 | - if(!file_exists($file_name)) { |
|
| 316 | - $custom_output = $file_name . ' does not exist'; |
|
| 317 | - } else { |
|
| 318 | - ob_start(); |
|
| 319 | - include $file_name; |
|
| 320 | - $custom_output = ob_get_contents(); |
|
| 321 | - ob_end_clean(); |
|
| 322 | - } |
|
| 323 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
| 324 | - $chunk_name = trim(substr($field_elements, 7)); |
|
| 325 | - $chunk_body = $modx->getChunk($chunk_name); |
|
| 326 | - if($chunk_body == false) { |
|
| 327 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
| 328 | - } else { |
|
| 329 | - $custom_output = $chunk_body; |
|
| 330 | - } |
|
| 331 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
| 332 | - $eval_str = trim(substr($field_elements, 6)); |
|
| 333 | - $custom_output = eval($eval_str); |
|
| 334 | - } else { |
|
| 335 | - $custom_output = $field_elements; |
|
| 336 | - } |
|
| 337 | - $replacements = array( |
|
| 338 | - '[+field_type+]' => $field_type, |
|
| 339 | - '[+field_id+]' => $field_id, |
|
| 340 | - '[+default_text+]' => $default_text, |
|
| 341 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
| 342 | - '[+field_style+]' => $field_style, |
|
| 343 | - ); |
|
| 344 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
| 345 | - $modx->documentObject = $content; |
|
| 346 | - $modx->documentIdentifier = $content['id']; |
|
| 347 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
| 348 | - $field_html .= $custom_output; |
|
| 349 | - break; |
|
| 303 | + case 'custom_tv': |
|
| 304 | + $custom_output = ''; |
|
| 305 | + /* If we are loading a file */ |
|
| 306 | + if(substr($field_elements, 0, 5) == "@FILE") { |
|
| 307 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
| 308 | + if(!file_exists($file_name)) { |
|
| 309 | + $custom_output = $file_name . ' does not exist'; |
|
| 310 | + } else { |
|
| 311 | + $custom_output = file_get_contents($file_name); |
|
| 312 | + } |
|
| 313 | + } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
| 314 | + $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
| 315 | + if(!file_exists($file_name)) { |
|
| 316 | + $custom_output = $file_name . ' does not exist'; |
|
| 317 | + } else { |
|
| 318 | + ob_start(); |
|
| 319 | + include $file_name; |
|
| 320 | + $custom_output = ob_get_contents(); |
|
| 321 | + ob_end_clean(); |
|
| 322 | + } |
|
| 323 | + } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
| 324 | + $chunk_name = trim(substr($field_elements, 7)); |
|
| 325 | + $chunk_body = $modx->getChunk($chunk_name); |
|
| 326 | + if($chunk_body == false) { |
|
| 327 | + $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
| 328 | + } else { |
|
| 329 | + $custom_output = $chunk_body; |
|
| 330 | + } |
|
| 331 | + } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
| 332 | + $eval_str = trim(substr($field_elements, 6)); |
|
| 333 | + $custom_output = eval($eval_str); |
|
| 334 | + } else { |
|
| 335 | + $custom_output = $field_elements; |
|
| 336 | + } |
|
| 337 | + $replacements = array( |
|
| 338 | + '[+field_type+]' => $field_type, |
|
| 339 | + '[+field_id+]' => $field_id, |
|
| 340 | + '[+default_text+]' => $default_text, |
|
| 341 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
| 342 | + '[+field_style+]' => $field_style, |
|
| 343 | + ); |
|
| 344 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
| 345 | + $modx->documentObject = $content; |
|
| 346 | + $modx->documentIdentifier = $content['id']; |
|
| 347 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
| 348 | + $field_html .= $custom_output; |
|
| 349 | + break; |
|
| 350 | 350 | |
| 351 | - default: // the default handler -- for errors, mostly |
|
| 352 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
| 351 | + default: // the default handler -- for errors, mostly |
|
| 352 | + $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
| 353 | 353 | |
| 354 | - } // end switch statement |
|
| 355 | - } else { |
|
| 356 | - $custom = explode(":", $field_type); |
|
| 357 | - $custom_output = ''; |
|
| 358 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
| 359 | - if(!file_exists($file_name)) { |
|
| 360 | - $custom_output = $file_name . ' does not exist'; |
|
| 361 | - } else { |
|
| 362 | - ob_start(); |
|
| 363 | - include $file_name; |
|
| 364 | - $custom_output = ob_get_contents(); |
|
| 365 | - ob_end_clean(); |
|
| 366 | - } |
|
| 367 | - $replacements = array( |
|
| 368 | - '[+field_type+]' => $field_type, |
|
| 369 | - '[+field_id+]' => $field_id, |
|
| 370 | - '[+default_text+]' => $default_text, |
|
| 371 | - '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
| 372 | - '[+field_style+]' => $field_style, |
|
| 373 | - ); |
|
| 374 | - $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
| 375 | - $modx->documentObject = $content; |
|
| 376 | - $custom_output = $modx->parseDocumentSource($custom_output); |
|
| 377 | - $field_html .= $custom_output; |
|
| 378 | - } |
|
| 354 | + } // end switch statement |
|
| 355 | + } else { |
|
| 356 | + $custom = explode(":", $field_type); |
|
| 357 | + $custom_output = ''; |
|
| 358 | + $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
| 359 | + if(!file_exists($file_name)) { |
|
| 360 | + $custom_output = $file_name . ' does not exist'; |
|
| 361 | + } else { |
|
| 362 | + ob_start(); |
|
| 363 | + include $file_name; |
|
| 364 | + $custom_output = ob_get_contents(); |
|
| 365 | + ob_end_clean(); |
|
| 366 | + } |
|
| 367 | + $replacements = array( |
|
| 368 | + '[+field_type+]' => $field_type, |
|
| 369 | + '[+field_id+]' => $field_id, |
|
| 370 | + '[+default_text+]' => $default_text, |
|
| 371 | + '[+field_value+]' => $modx->htmlspecialchars($field_value), |
|
| 372 | + '[+field_style+]' => $field_style, |
|
| 373 | + ); |
|
| 374 | + $custom_output = str_replace(array_keys($replacements), $replacements, $custom_output); |
|
| 375 | + $modx->documentObject = $content; |
|
| 376 | + $custom_output = $modx->parseDocumentSource($custom_output); |
|
| 377 | + $field_html .= $custom_output; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - return $field_html; |
|
| 380 | + return $field_html; |
|
| 381 | 381 | } // end renderFormElement function |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -386,13 +386,13 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function ParseIntputOptions($v) { |
| 388 | 388 | $modx = evolutionCMS(); |
| 389 | - $a = array(); |
|
| 390 | - if(is_array($v)) { |
|
| 391 | - return $v; |
|
| 392 | - } else if($modx->db->isResult($v)) { |
|
| 393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
| 394 | - } else { |
|
| 395 | - $a = explode("||", $v); |
|
| 396 | - } |
|
| 397 | - return $a; |
|
| 389 | + $a = array(); |
|
| 390 | + if(is_array($v)) { |
|
| 391 | + return $v; |
|
| 392 | + } else if($modx->db->isResult($v)) { |
|
| 393 | + while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
| 394 | + } else { |
|
| 395 | + $a = explode("||", $v); |
|
| 396 | + } |
|
| 397 | + return $a; |
|
| 398 | 398 | } |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | * @param array $tvsArray |
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | -function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
|
| 15 | +function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()){ |
|
| 16 | 16 | $modx = evolutionCMS(); |
| 17 | 17 | global $_style; |
| 18 | 18 | global $_lang; |
| 19 | 19 | global $content; |
| 20 | 20 | global $which_browser; |
| 21 | 21 | |
| 22 | - if(substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
| 22 | + if (substr($default_text, 0, 6) === '@@EVAL' && $field_value === $default_text) { |
|
| 23 | 23 | $eval_str = trim(substr($default_text, 7)); |
| 24 | 24 | $default_text = eval($eval_str); |
| 25 | 25 | $field_value = $default_text; |
@@ -27,74 +27,74 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $field_html = ''; |
| 29 | 29 | $cimode = strpos($field_type, ':'); |
| 30 | - if($cimode === false) { |
|
| 31 | - switch($field_type) { |
|
| 30 | + if ($cimode === false) { |
|
| 31 | + switch ($field_type) { |
|
| 32 | 32 | |
| 33 | 33 | case "text": // handler for regular text boxes |
| 34 | 34 | case "rawtext"; // non-htmlentity converted text boxes |
| 35 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />'; |
|
| 35 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" />'; |
|
| 36 | 36 | break; |
| 37 | 37 | case "email": // handles email input fields |
| 38 | - $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>'; |
|
| 38 | + $field_html .= '<input type="email" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%"/>'; |
|
| 39 | 39 | break; |
| 40 | 40 | case "number": // handles the input of numbers |
| 41 | - $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
| 41 | + $field_html .= '<input type="number" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>'; |
|
| 42 | 42 | break; |
| 43 | 43 | case "textareamini": // handler for textarea mini boxes |
| 44 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 44 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
| 45 | 45 | break; |
| 46 | 46 | case "textarea": // handler for textarea boxes |
| 47 | 47 | case "rawtextarea": // non-htmlentity convertex textarea boxes |
| 48 | 48 | case "htmlarea": // handler for textarea boxes (deprecated) |
| 49 | 49 | case "richtext": // handler for textarea boxes |
| 50 | - $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>'; |
|
| 50 | + $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>'; |
|
| 51 | 51 | break; |
| 52 | 52 | case "date": |
| 53 | 53 | $field_id = str_replace(array( |
| 54 | 54 | '-', |
| 55 | 55 | '.' |
| 56 | 56 | ), '_', urldecode($field_id)); |
| 57 | - if($field_value == '') { |
|
| 57 | + if ($field_value == '') { |
|
| 58 | 58 | $field_value = 0; |
| 59 | 59 | } |
| 60 | - $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />'; |
|
| 61 | - $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>'; |
|
| 60 | + $field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="'.($field_value == 0 || !isset($field_value) ? "" : $field_value).'" onblur="documentDirty=true;" />'; |
|
| 61 | + $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="'.$_style["actions_calendar_delete"].'"></i></a>'; |
|
| 62 | 62 | |
| 63 | 63 | break; |
| 64 | 64 | case "dropdown": // handler for select boxes |
| 65 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">'; |
|
| 65 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" size="1" onchange="documentDirty=true;">'; |
|
| 66 | 66 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
| 67 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 67 | + while (list($item, $itemvalue) = each($index_list)) { |
|
| 68 | 68 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
| 69 | - if(strlen($itemvalue) == 0) { |
|
| 69 | + if (strlen($itemvalue) == 0) { |
|
| 70 | 70 | $itemvalue = $item; |
| 71 | 71 | } |
| 72 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 72 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
| 73 | 73 | } |
| 74 | 74 | $field_html .= "</select>"; |
| 75 | 75 | break; |
| 76 | 76 | case "listbox": // handler for select boxes |
| 77 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">'; |
|
| 77 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" onchange="documentDirty=true;" size="8">'; |
|
| 78 | 78 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
| 79 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 79 | + while (list($item, $itemvalue) = each($index_list)) { |
|
| 80 | 80 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
| 81 | - if(strlen($itemvalue) == 0) { |
|
| 81 | + if (strlen($itemvalue) == 0) { |
|
| 82 | 82 | $itemvalue = $item; |
| 83 | 83 | } |
| 84 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 84 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
| 85 | 85 | } |
| 86 | 86 | $field_html .= "</select>"; |
| 87 | 87 | break; |
| 88 | 88 | case "listbox-multiple": // handler for select boxes where you can choose multiple items |
| 89 | 89 | $field_value = explode("||", $field_value); |
| 90 | - $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
| 90 | + $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'[]" multiple="multiple" onchange="documentDirty=true;" size="8">'; |
|
| 91 | 91 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
| 92 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 92 | + while (list($item, $itemvalue) = each($index_list)) { |
|
| 93 | 93 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
| 94 | - if(strlen($itemvalue) == 0) { |
|
| 94 | + if (strlen($itemvalue) == 0) { |
|
| 95 | 95 | $itemvalue = $item; |
| 96 | 96 | } |
| 97 | - $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>'; |
|
| 97 | + $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.(in_array($itemvalue, $field_value) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>'; |
|
| 98 | 98 | } |
| 99 | 99 | $field_html .= "</select>"; |
| 100 | 100 | break; |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | 'ftp://' => 'ftp://', |
| 107 | 107 | 'mailto:' => 'mailto:' |
| 108 | 108 | ); |
| 109 | - $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">'; |
|
| 110 | - foreach($urls as $k => $v) { |
|
| 111 | - if(strpos($field_value, $v) === false) { |
|
| 112 | - $field_html .= '<option value="' . $v . '">' . $k . '</option>'; |
|
| 109 | + $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_id.'_prefix" name="tv'.$field_id.'_prefix" onchange="documentDirty=true;">'; |
|
| 110 | + foreach ($urls as $k => $v) { |
|
| 111 | + if (strpos($field_value, $v) === false) { |
|
| 112 | + $field_html .= '<option value="'.$v.'">'.$k.'</option>'; |
|
| 113 | 113 | } else { |
| 114 | 114 | $field_value = str_replace($v, '', $field_value); |
| 115 | - $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>'; |
|
| 115 | + $field_html .= '<option value="'.$v.'" selected="selected">'.$k.'</option>'; |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | $field_html .= '</select></td><td>'; |
| 119 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>'; |
|
| 119 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>'; |
|
| 120 | 120 | break; |
| 121 | 121 | case 'checkbox': // handles check boxes |
| 122 | 122 | $values = !is_array($field_value) ? explode('||', $field_value) : $field_value; |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | $tpl = '<label class="checkbox"><input type="checkbox" value="%s" id="tv_%s" name="tv%s[]" %s onchange="documentDirty=true;" />%s</label><br />'; |
| 125 | 125 | static $i = 0; |
| 126 | 126 | $_ = array(); |
| 127 | - foreach($index_list as $c => $item) { |
|
| 128 | - if(is_array($item)) { |
|
| 127 | + foreach ($index_list as $c => $item) { |
|
| 128 | + if (is_array($item)) { |
|
| 129 | 129 | $name = trim($item[0]); |
| 130 | 130 | $value = isset($item[1]) ? $item[1] : $name; |
| 131 | 131 | } else { |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | case "option": // handles radio buttons |
| 152 | 152 | $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray)); |
| 153 | 153 | static $i = 0; |
| 154 | - while(list($item, $itemvalue) = each($index_list)) { |
|
| 154 | + while (list($item, $itemvalue) = each($index_list)) { |
|
| 155 | 155 | list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); |
| 156 | - if(strlen($itemvalue) == 0) { |
|
| 156 | + if (strlen($itemvalue) == 0) { |
|
| 157 | 157 | $itemvalue = $item; |
| 158 | 158 | } |
| 159 | - $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />'; |
|
| 159 | + $field_html .= '<input type="radio" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'" '.($itemvalue == $field_value ? 'checked="checked"' : '').' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="radio">'.$item.'</label><br />'; |
|
| 160 | 160 | $i++; |
| 161 | 161 | } |
| 162 | 162 | break; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | global $_lang; |
| 165 | 165 | global $ResourceManagerLoaded; |
| 166 | 166 | global $content, $use_editor, $which_editor; |
| 167 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 167 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 168 | 168 | $field_html .= " |
| 169 | 169 | <script type=\"text/javascript\"> |
| 170 | 170 | /* <![CDATA[ */ |
@@ -186,13 +186,13 @@ discard block |
||
| 186 | 186 | lastImageCtrl = ctrl; |
| 187 | 187 | var w = screen.width * 0.5; |
| 188 | 188 | var h = screen.height * 0.5; |
| 189 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
| 189 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
| 190 | 190 | } |
| 191 | 191 | function BrowseFileServer(ctrl) { |
| 192 | 192 | lastFileCtrl = ctrl; |
| 193 | 193 | var w = screen.width * 0.5; |
| 194 | 194 | var h = screen.height * 0.5; |
| 195 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
| 195 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
| 196 | 196 | } |
| 197 | 197 | function SetUrlChange(el) { |
| 198 | 198 | if ('createEvent' in document) { |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | </script>"; |
| 227 | 227 | $ResourceManagerLoaded = true; |
| 228 | 228 | } |
| 229 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />'; |
|
| 229 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseServer(\'tv'.$field_id.'\')" />'; |
|
| 230 | 230 | break; |
| 231 | 231 | case "file": // handles the input of file uploads |
| 232 | 232 | /* Modified by Timon for use with resource browser */ |
| 233 | 233 | global $_lang; |
| 234 | 234 | global $ResourceManagerLoaded; |
| 235 | 235 | global $content, $use_editor, $which_editor; |
| 236 | - if(!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 236 | + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $modx->manager->action == 4) && $use_editor == 1 && $which_editor == 3)) { |
|
| 237 | 237 | /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ |
| 238 | 238 | $field_html .= " |
| 239 | 239 | <script type=\"text/javascript\"> |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | lastImageCtrl = ctrl; |
| 257 | 257 | var w = screen.width * 0.5; |
| 258 | 258 | var h = screen.height * 0.5; |
| 259 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
| 259 | + OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h); |
|
| 260 | 260 | } |
| 261 | 261 | function BrowseFileServer(ctrl) { |
| 262 | 262 | lastFileCtrl = ctrl; |
| 263 | 263 | var w = screen.width * 0.5; |
| 264 | 264 | var h = screen.height * 0.5; |
| 265 | - OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
| 265 | + OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h); |
|
| 266 | 266 | } |
| 267 | 267 | function SetUrlChange(el) { |
| 268 | 268 | if ('createEvent' in document) { |
@@ -296,39 +296,39 @@ discard block |
||
| 296 | 296 | </script>"; |
| 297 | 297 | $ResourceManagerLoaded = true; |
| 298 | 298 | } |
| 299 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />'; |
|
| 299 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />'; |
|
| 300 | 300 | |
| 301 | 301 | break; |
| 302 | 302 | |
| 303 | 303 | case 'custom_tv': |
| 304 | 304 | $custom_output = ''; |
| 305 | 305 | /* If we are loading a file */ |
| 306 | - if(substr($field_elements, 0, 5) == "@FILE") { |
|
| 307 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6)); |
|
| 308 | - if(!file_exists($file_name)) { |
|
| 309 | - $custom_output = $file_name . ' does not exist'; |
|
| 306 | + if (substr($field_elements, 0, 5) == "@FILE") { |
|
| 307 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 6)); |
|
| 308 | + if (!file_exists($file_name)) { |
|
| 309 | + $custom_output = $file_name.' does not exist'; |
|
| 310 | 310 | } else { |
| 311 | 311 | $custom_output = file_get_contents($file_name); |
| 312 | 312 | } |
| 313 | - } elseif(substr($field_elements, 0, 8) == '@INCLUDE') { |
|
| 314 | - $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9)); |
|
| 315 | - if(!file_exists($file_name)) { |
|
| 316 | - $custom_output = $file_name . ' does not exist'; |
|
| 313 | + } elseif (substr($field_elements, 0, 8) == '@INCLUDE') { |
|
| 314 | + $file_name = MODX_BASE_PATH.trim(substr($field_elements, 9)); |
|
| 315 | + if (!file_exists($file_name)) { |
|
| 316 | + $custom_output = $file_name.' does not exist'; |
|
| 317 | 317 | } else { |
| 318 | 318 | ob_start(); |
| 319 | 319 | include $file_name; |
| 320 | 320 | $custom_output = ob_get_contents(); |
| 321 | 321 | ob_end_clean(); |
| 322 | 322 | } |
| 323 | - } elseif(substr($field_elements, 0, 6) == "@CHUNK") { |
|
| 323 | + } elseif (substr($field_elements, 0, 6) == "@CHUNK") { |
|
| 324 | 324 | $chunk_name = trim(substr($field_elements, 7)); |
| 325 | 325 | $chunk_body = $modx->getChunk($chunk_name); |
| 326 | - if($chunk_body == false) { |
|
| 327 | - $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')'; |
|
| 326 | + if ($chunk_body == false) { |
|
| 327 | + $custom_output = $_lang['chunk_no_exist'].'('.$_lang['htmlsnippet_name'].':'.$chunk_name.')'; |
|
| 328 | 328 | } else { |
| 329 | 329 | $custom_output = $chunk_body; |
| 330 | 330 | } |
| 331 | - } elseif(substr($field_elements, 0, 5) == "@EVAL") { |
|
| 331 | + } elseif (substr($field_elements, 0, 5) == "@EVAL") { |
|
| 332 | 332 | $eval_str = trim(substr($field_elements, 6)); |
| 333 | 333 | $custom_output = eval($eval_str); |
| 334 | 334 | } else { |
@@ -349,15 +349,15 @@ discard block |
||
| 349 | 349 | break; |
| 350 | 350 | |
| 351 | 351 | default: // the default handler -- for errors, mostly |
| 352 | - $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />'; |
|
| 352 | + $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />'; |
|
| 353 | 353 | |
| 354 | 354 | } // end switch statement |
| 355 | 355 | } else { |
| 356 | 356 | $custom = explode(":", $field_type); |
| 357 | 357 | $custom_output = ''; |
| 358 | - $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php'; |
|
| 359 | - if(!file_exists($file_name)) { |
|
| 360 | - $custom_output = $file_name . ' does not exist'; |
|
| 358 | + $file_name = MODX_BASE_PATH.'assets/tvs/'.$custom['1'].'/'.$custom['1'].'.customtv.php'; |
|
| 359 | + if (!file_exists($file_name)) { |
|
| 360 | + $custom_output = $file_name.' does not exist'; |
|
| 361 | 361 | } else { |
| 362 | 362 | ob_start(); |
| 363 | 363 | include $file_name; |
@@ -384,13 +384,13 @@ discard block |
||
| 384 | 384 | * @param string|array|mysqli_result $v |
| 385 | 385 | * @return array |
| 386 | 386 | */ |
| 387 | -function ParseIntputOptions($v) { |
|
| 387 | +function ParseIntputOptions($v){ |
|
| 388 | 388 | $modx = evolutionCMS(); |
| 389 | 389 | $a = array(); |
| 390 | - if(is_array($v)) { |
|
| 390 | + if (is_array($v)) { |
|
| 391 | 391 | return $v; |
| 392 | - } else if($modx->db->isResult($v)) { |
|
| 393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
| 392 | + } else if ($modx->db->isResult($v)) { |
|
| 393 | + while ($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
| 394 | 394 | } else { |
| 395 | 395 | $a = explode("||", $v); |
| 396 | 396 | } |
@@ -12,7 +12,8 @@ discard block |
||
| 12 | 12 | * @param array $tvsArray |
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | -function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) { |
|
| 15 | +function renderFormElement($field_type, $field_id, $default_text = '', $field_elements = '', $field_value = '', $field_style = '', $row = array(), $tvsArray = array()) |
|
| 16 | +{ |
|
| 16 | 17 | $modx = evolutionCMS(); |
| 17 | 18 | global $_style; |
| 18 | 19 | global $_lang; |
@@ -384,13 +385,16 @@ discard block |
||
| 384 | 385 | * @param string|array|mysqli_result $v |
| 385 | 386 | * @return array |
| 386 | 387 | */ |
| 387 | -function ParseIntputOptions($v) { |
|
| 388 | +function ParseIntputOptions($v) |
|
| 389 | +{ |
|
| 388 | 390 | $modx = evolutionCMS(); |
| 389 | 391 | $a = array(); |
| 390 | 392 | if(is_array($v)) { |
| 391 | 393 | return $v; |
| 392 | 394 | } else if($modx->db->isResult($v)) { |
| 393 | - while($cols = $modx->db->getRow($v, 'num')) $a[] = $cols; |
|
| 395 | + while($cols = $modx->db->getRow($v, 'num')) { |
|
| 396 | + $a[] = $cols; |
|
| 397 | + } |
|
| 394 | 398 | } else { |
| 395 | 399 | $a = explode("||", $v); |
| 396 | 400 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | $modx->getSettings(); |
| 6 | 6 | $modx->invokeEvent('OnWebPageInit'); |
| 7 | 7 | |
| 8 | -$vword = new VeriWord(148,60); |
|
| 8 | +$vword = new VeriWord(148, 60); |
|
| 9 | 9 | $vword->output_image(); |
| 10 | 10 | $vword->destroy_image(); |
| 11 | 11 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord{ |
|
| 45 | 45 | |
| 46 | 46 | /* path to font directory*/ |
| 47 | 47 | public $dir_font = "ttf/"; |
@@ -52,44 +52,44 @@ discard block |
||
| 52 | 52 | public $im_height = 0; |
| 53 | 53 | public $im; |
| 54 | 54 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 55 | + public function __construct($w = 200, $h = 80){ |
|
| 56 | 56 | /* create session to set word for verification */ |
| 57 | 57 | $this->set_veriword(); |
| 58 | - $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
|
| 58 | + $this->dir_font = dirname(__FILE__).'/'.$this->dir_font; |
|
| 59 | 59 | $this->im_width = $w; |
| 60 | 60 | $this->im_height = $h; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function set_veriword() { |
|
| 63 | + public function set_veriword(){ |
|
| 64 | 64 | /* create session variable for verification, |
| 65 | 65 | you may change the session variable name */ |
| 66 | 66 | $this->word = $this->pick_word(); |
| 67 | 67 | $_SESSION['veriword'] = $this->word; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function output_image() { |
|
| 70 | + public function output_image(){ |
|
| 71 | 71 | /* output the image as jpeg */ |
| 72 | 72 | $this->draw_image(); |
| 73 | 73 | header("Content-type: image/jpeg"); |
| 74 | 74 | imagejpeg($this->im); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function pick_word() { |
|
| 77 | + public function pick_word(){ |
|
| 78 | 78 | $modx = evolutionCMS(); |
| 79 | 79 | // set default words |
| 80 | - $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 80 | + $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 81 | 81 | $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words; |
| 82 | 82 | $arr_words = array_filter(array_map('trim', explode(',', $words))); |
| 83 | 83 | |
| 84 | 84 | /* pick one randomly for text verification */ |
| 85 | - return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
|
| 85 | + return (string) $arr_words[array_rand($arr_words)].rand(10, 999); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function draw_text() { |
|
| 88 | + public function draw_text(){ |
|
| 89 | 89 | $dir = dir($this->dir_font); |
| 90 | 90 | $fontstmp = array(); |
| 91 | 91 | while (false !== ($file = $dir->read())) { |
| 92 | - if(substr($file, -4) == '.ttf') { |
|
| 92 | + if (substr($file, -4) == '.ttf') { |
|
| 93 | 93 | $fontstmp[] = $this->dir_font.$file; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -97,35 +97,35 @@ discard block |
||
| 97 | 97 | $text_font = (string) $fontstmp[array_rand($fontstmp)]; |
| 98 | 98 | |
| 99 | 99 | /* angle for text inclination */ |
| 100 | - $text_angle = rand(-9,9); |
|
| 100 | + $text_angle = rand(-9, 9); |
|
| 101 | 101 | /* initial text size */ |
| 102 | 102 | $text_size = 30; |
| 103 | 103 | /* calculate text width and height */ |
| 104 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 105 | - $text_width = $box[2]-$box[0]; //text width |
|
| 106 | - $text_height= $box[5]-$box[3]; //text height |
|
| 104 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 105 | + $text_width = $box[2] - $box[0]; //text width |
|
| 106 | + $text_height = $box[5] - $box[3]; //text height |
|
| 107 | 107 | |
| 108 | 108 | /* adjust text size */ |
| 109 | - $text_size = round((20 * $this->im_width)/$text_width); |
|
| 109 | + $text_size = round((20 * $this->im_width) / $text_width); |
|
| 110 | 110 | |
| 111 | 111 | /* recalculate text width and height */ |
| 112 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 113 | - $text_width = $box[2]-$box[0]; //text width |
|
| 114 | - $text_height= $box[5]-$box[3]; //text height |
|
| 112 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 113 | + $text_width = $box[2] - $box[0]; //text width |
|
| 114 | + $text_height = $box[5] - $box[3]; //text height |
|
| 115 | 115 | |
| 116 | 116 | /* calculate center position of text */ |
| 117 | - $text_x = ($this->im_width - $text_width)/2; |
|
| 118 | - $text_y = ($this->im_height - $text_height)/2; |
|
| 117 | + $text_x = ($this->im_width - $text_width) / 2; |
|
| 118 | + $text_y = ($this->im_height - $text_height) / 2; |
|
| 119 | 119 | |
| 120 | 120 | /* create canvas for text drawing */ |
| 121 | - $im_text = imagecreate ($this->im_width, $this->im_height); |
|
| 122 | - $bg_color = imagecolorallocate ($im_text, 255, 255, 255); |
|
| 121 | + $im_text = imagecreate($this->im_width, $this->im_height); |
|
| 122 | + $bg_color = imagecolorallocate($im_text, 255, 255, 255); |
|
| 123 | 123 | |
| 124 | 124 | /* pick color for text */ |
| 125 | - $text_color = imagecolorallocate ($im_text, 0, 51, 153); |
|
| 125 | + $text_color = imagecolorallocate($im_text, 0, 51, 153); |
|
| 126 | 126 | |
| 127 | 127 | /* draw text into canvas */ |
| 128 | - imagettftext ( $im_text, |
|
| 128 | + imagettftext($im_text, |
|
| 129 | 129 | $text_size, |
| 130 | 130 | $text_angle, |
| 131 | 131 | $text_x, |
@@ -140,19 +140,19 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - public function draw_image() { |
|
| 143 | + public function draw_image(){ |
|
| 144 | 144 | |
| 145 | 145 | /* pick one background image randomly from image directory */ |
| 146 | - $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
|
| 146 | + $img_file = $this->dir_noise."noise".rand(1, 4).".jpg"; |
|
| 147 | 147 | |
| 148 | 148 | /* create "noise" background image from your image stock*/ |
| 149 | - $noise_img = @imagecreatefromjpeg ($img_file); |
|
| 149 | + $noise_img = @imagecreatefromjpeg($img_file); |
|
| 150 | 150 | $noise_width = imagesx($noise_img); |
| 151 | 151 | $noise_height = imagesy($noise_img); |
| 152 | 152 | |
| 153 | 153 | /* resize the background image to fit the size of image output */ |
| 154 | - $this->im = imagecreatetruecolor($this->im_width,$this->im_height); |
|
| 155 | - imagecopyresampled ($this->im, |
|
| 154 | + $this->im = imagecreatetruecolor($this->im_width, $this->im_height); |
|
| 155 | + imagecopyresampled($this->im, |
|
| 156 | 156 | $noise_img, |
| 157 | 157 | 0, 0, 0, 0, |
| 158 | 158 | $this->im_width, |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | $noise_height); |
| 162 | 162 | |
| 163 | 163 | /* put text image into background image */ |
| 164 | - imagecopymerge ( $this->im, |
|
| 164 | + imagecopymerge($this->im, |
|
| 165 | 165 | $this->draw_text(), |
| 166 | 166 | 0, 0, 0, 0, |
| 167 | 167 | $this->im_width, |
| 168 | 168 | $this->im_height, |
| 169 | - 70 ); |
|
| 169 | + 70); |
|
| 170 | 170 | |
| 171 | 171 | return $this->im; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function destroy_image() { |
|
| 174 | + public function destroy_image(){ |
|
| 175 | 175 | |
| 176 | 176 | imagedestroy($this->im); |
| 177 | 177 | |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord |
|
| 45 | +{ |
|
| 45 | 46 | |
| 46 | 47 | /* path to font directory*/ |
| 47 | 48 | public $dir_font = "ttf/"; |
@@ -52,7 +53,8 @@ discard block |
||
| 52 | 53 | public $im_height = 0; |
| 53 | 54 | public $im; |
| 54 | 55 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 56 | + public function __construct($w=200, $h=80) |
|
| 57 | + { |
|
| 56 | 58 | /* create session to set word for verification */ |
| 57 | 59 | $this->set_veriword(); |
| 58 | 60 | $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
@@ -60,21 +62,24 @@ discard block |
||
| 60 | 62 | $this->im_height = $h; |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | - public function set_veriword() { |
|
| 65 | + public function set_veriword() |
|
| 66 | + { |
|
| 64 | 67 | /* create session variable for verification, |
| 65 | 68 | you may change the session variable name */ |
| 66 | 69 | $this->word = $this->pick_word(); |
| 67 | 70 | $_SESSION['veriword'] = $this->word; |
| 68 | 71 | } |
| 69 | 72 | |
| 70 | - public function output_image() { |
|
| 73 | + public function output_image() |
|
| 74 | + { |
|
| 71 | 75 | /* output the image as jpeg */ |
| 72 | 76 | $this->draw_image(); |
| 73 | 77 | header("Content-type: image/jpeg"); |
| 74 | 78 | imagejpeg($this->im); |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | - public function pick_word() { |
|
| 81 | + public function pick_word() |
|
| 82 | + { |
|
| 78 | 83 | $modx = evolutionCMS(); |
| 79 | 84 | // set default words |
| 80 | 85 | $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
@@ -85,7 +90,8 @@ discard block |
||
| 85 | 90 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
| 86 | 91 | } |
| 87 | 92 | |
| 88 | - public function draw_text() { |
|
| 93 | + public function draw_text() |
|
| 94 | + { |
|
| 89 | 95 | $dir = dir($this->dir_font); |
| 90 | 96 | $fontstmp = array(); |
| 91 | 97 | while (false !== ($file = $dir->read())) { |
@@ -140,7 +146,8 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | |
| 142 | 148 | |
| 143 | - public function draw_image() { |
|
| 149 | + public function draw_image() |
|
| 150 | + { |
|
| 144 | 151 | |
| 145 | 152 | /* pick one background image randomly from image directory */ |
| 146 | 153 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -171,7 +178,8 @@ discard block |
||
| 171 | 178 | return $this->im; |
| 172 | 179 | } |
| 173 | 180 | |
| 174 | - public function destroy_image() { |
|
| 181 | + public function destroy_image() |
|
| 182 | + { |
|
| 175 | 183 | |
| 176 | 184 | imagedestroy($this->im); |
| 177 | 185 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function setTableWidth($value) |
| 132 | 132 | { |
| 133 | - $this->tableWidth = (int)$value; |
|
| 133 | + $this->tableWidth = (int) $value; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | { |
| 318 | 318 | $currentWidth = ''; |
| 319 | 319 | if (is_array($this->columnWidths)) { |
| 320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
| 320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $currentClass = $this->rowAlternateClass; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return ' class="' . $currentClass . '"'; |
|
| 349 | + return ' class="'.$currentClass.'"'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $cellAction = ''; |
| 362 | 362 | if ($this->cellAction) { |
| 363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
| 363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | $cell = $value; |
| 379 | 379 | if ($this->linkAction) { |
| 380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
| 380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $end = '?'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - return $link . $end; |
|
| 409 | + return $link.$end; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (is_array($fieldsArray)) { |
| 427 | 427 | $i = 0; |
| 428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
| 429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
| 429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
| 430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
| 431 | 431 | if (is_array($this->selectedValues)) { |
| 432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | $colPosition = 0; |
| 438 | 438 | foreach ($fieldValue as $key => $value) { |
| 439 | 439 | if (!in_array($key, $this->excludeFields)) { |
| 440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
| 440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
| 441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
| 442 | 442 | $table .= "</td>\n"; |
| 443 | 443 | if ($i == 0) { |
| 444 | 444 | if (empty ($header) && $this->formElementType) { |
| 445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
| 445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
| 446 | 446 | } |
| 447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
| 448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
| 448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
| 449 | 449 | } |
| 450 | 450 | $colPosition++; |
| 451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
| 453 | 453 | $i++; |
| 454 | 454 | $table .= "\t</tr>\n"; |
| 455 | 455 | } |
| 456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
| 456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
| 457 | 457 | if ($this->formElementType) { |
| 458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
| 458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
| 459 | 459 | } |
| 460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
| 461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
| 471 | 471 | */ |
| 472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
| 472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
| 473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
| 474 | 474 | |
| 475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | <script language="javascript"> |
| 479 | 479 | toggled = 0; |
| 480 | 480 | function clickAll() { |
| 481 | - myform = document.getElementById("' . $this->formName . '"); |
|
| 481 | + myform = document.getElementById("' . $this->formName.'"); |
|
| 482 | 482 | for(i=0;i<myform.length;i++) { |
| 483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
| 484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | if ($this->formElementType) { |
| 492 | 492 | if ($this->extra) { |
| 493 | - $table .= "\n" . $this->extra . "\n"; |
|
| 493 | + $table .= "\n".$this->extra."\n"; |
|
| 494 | 494 | } |
| 495 | - $table .= "\n" . '</form>' . "\n"; |
|
| 495 | + $table .= "\n".'</form>'."\n"; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
| 516 | 516 | $nav = ''; |
| 517 | 517 | if ($numPages > 1) { |
| 518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
| 518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
| 519 | 519 | if ($currentPage > 6) { |
| 520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
| 521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - $this->pageNav = ' ' . $nav; |
|
| 543 | + $this->pageNav = ' '.$nav; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
| 557 | 557 | { |
| 558 | 558 | $modx = evolutionCMS(); |
| 559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
| 560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
| 559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
| 560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
| 561 | 561 | if (!empty($qs)) { |
| 562 | 562 | $qs = "?$qs"; |
| 563 | 563 | } |
| 564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
| 565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
| 566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
| 565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
| 566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
| 567 | 567 | |
| 568 | 568 | return $nav; |
| 569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $field = ''; |
| 582 | 582 | if ($this->formElementType) { |
| 583 | 583 | $checked = $isChecked ? "checked " : ""; |
| 584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
| 584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | public function handlePaging() |
| 596 | 596 | { |
| 597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
| 598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
| 598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
| 599 | 599 | |
| 600 | 600 | return $limitClause; |
| 601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | public function handleSorting($natural_order = false) |
| 611 | 611 | { |
| 612 | 612 | $orderByClause = ''; |
| 613 | - if ((bool)$natural_order === false) { |
|
| 613 | + if ((bool) $natural_order === false) { |
|
| 614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
| 615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
| 616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
| 616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
| 645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | } |
@@ -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'])) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->count = 0; |
| 58 | 58 | $this->setUrlMode(); |
| 59 | 59 | $this->generate_mode = 'crawl'; |
| 60 | - $this->targetDir = $modx->config['base_path'] . 'temp/export'; |
|
| 60 | + $this->targetDir = $modx->config['base_path'].'temp/export'; |
|
| 61 | 61 | if (!isset($this->total)) { |
| 62 | 62 | $this->getTotal(); |
| 63 | 63 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids))); |
| 114 | 114 | if (count($ignore_ids) > 0) { |
| 115 | - $ignore_ids = "AND NOT id IN ('" . implode("','", $ignore_ids) . "')"; |
|
| 115 | + $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')"; |
|
| 116 | 116 | } else { |
| 117 | 117 | $ignore_ids = ''; |
| 118 | 118 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $noncache = ($noncache == 1) ? '' : 'AND cacheable=1'; |
| 123 | 123 | $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}"; |
| 124 | 124 | $rs = $modx->db->select('count(id)', $tbl_site_content, $where); |
| 125 | - $this->total = (int)$modx->db->getValue($rs); |
|
| 125 | + $this->total = (int) $modx->db->getValue($rs); |
|
| 126 | 126 | |
| 127 | 127 | return $this->total; |
| 128 | 128 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } elseif (!is_readable($directory)) { |
| 152 | 152 | return $rs; |
| 153 | 153 | } else { |
| 154 | - $files = glob($directory . '/*'); |
|
| 154 | + $files = glob($directory.'/*'); |
|
| 155 | 155 | if (!empty($files)) { |
| 156 | 156 | foreach ($files as $path) { |
| 157 | 157 | $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $_lang = $back_lang; |
| 182 | 182 | } else { |
| 183 | - $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
| 183 | + $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}"); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | $modx = evolutionCMS(); |
| 216 | 216 | |
| 217 | 217 | if ($alias === '') { |
| 218 | - $filename = $prefix . $docid . $suffix; |
|
| 218 | + $filename = $prefix.$docid.$suffix; |
|
| 219 | 219 | } else { |
| 220 | 220 | if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false) { |
| 221 | 221 | $suffix = ''; |
| 222 | 222 | } |
| 223 | - $filename = $prefix . $alias . $suffix; |
|
| 223 | + $filename = $prefix.$alias.$suffix; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | return $filename; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 239 | 239 | |
| 240 | 240 | $ignore_ids = $this->ignore_ids; |
| 241 | - $dirpath = $this->targetDir . '/'; |
|
| 241 | + $dirpath = $this->targetDir.'/'; |
|
| 242 | 242 | |
| 243 | 243 | $prefix = $modx->config['friendly_url_prefix']; |
| 244 | 244 | $suffix = $modx->config['friendly_url_suffix']; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | $ph['status'] = 'fail'; |
| 250 | 250 | $ph['msg1'] = $_lang['export_site_failed']; |
| 251 | - $ph['msg2'] = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath; |
|
| 251 | + $ph['msg2'] = $_lang["export_site_failed_no_write"].' - '.$dirpath; |
|
| 252 | 252 | $msg_failed_no_write = $this->parsePlaceholder($tpl, $ph); |
| 253 | 253 | |
| 254 | 254 | $ph['msg2'] = $_lang["export_site_failed_no_retrieve"]; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | if (!$row['wasNull']) { // needs writing a document |
| 283 | 283 | $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix); |
| 284 | - $filename = $dirpath . $docname; |
|
| 284 | + $filename = $dirpath.$docname; |
|
| 285 | 285 | if (!is_file($filename)) { |
| 286 | 286 | if ($row['published'] === '1') { |
| 287 | 287 | $status = $this->makeFile($row['id'], $filename); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'], |
| 310 | 310 | '.') === false)) { // needs making a folder |
| 311 | 311 | $end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id']; |
| 312 | - $dir_path = $dirpath . $end_dir; |
|
| 312 | + $dir_path = $dirpath.$end_dir; |
|
| 313 | 313 | if (strpos($dir_path, MODX_BASE_PATH) === false) { |
| 314 | 314 | return false; |
| 315 | 315 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | if ($modx->config['make_folders'] === '1' && $row['published'] === '1') { |
| 327 | 327 | if (!empty($filename) && is_file($filename)) { |
| 328 | - rename($filename, $dir_path . '/index.html'); |
|
| 328 | + rename($filename, $dir_path.'/index.html'); |
|
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | $this->targetDir = $dir_path; |
@@ -349,8 +349,8 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | $ch = curl_init(); |
| 351 | 351 | curl_setopt($ch, CURLOPT_URL, $url); |
| 352 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
| 353 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
| 352 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT |
|
| 353 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER |
|
| 354 | 354 | curl_setopt($ch, CURLOPT_HEADER, false); |
| 355 | 355 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 356 | 356 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |