@@ -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 | } |
@@ -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,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 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DataGrid { |
| 14 | 14 | |
| 15 | - public $ds; // datasource |
|
| 15 | + public $ds; // datasource |
|
| 16 | 16 | public $id; |
| 17 | 17 | public $pageSize; // pager settings |
| 18 | 18 | public $pageNumber; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public $colWraps; |
| 37 | 37 | public $colColors; |
| 38 | 38 | public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
| 39 | - // data type: integer,float,currency,date |
|
| 39 | + // data type: integer,float,currency,date |
|
| 40 | 40 | |
| 41 | 41 | public $header; |
| 42 | 42 | public $footer; |
@@ -73,239 +73,239 @@ discard block |
||
| 73 | 73 | public $cdelim; |
| 74 | 74 | |
| 75 | 75 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
| 76 | - global $__DataGridCnt; |
|
| 76 | + global $__DataGridCnt; |
|
| 77 | 77 | |
| 78 | - // set id |
|
| 79 | - $__DataGridCnt++; |
|
| 80 | - $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
| 78 | + // set id |
|
| 79 | + $__DataGridCnt++; |
|
| 80 | + $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt; |
|
| 81 | 81 | |
| 82 | - // set datasource |
|
| 83 | - $this->ds = $ds; |
|
| 82 | + // set datasource |
|
| 83 | + $this->ds = $ds; |
|
| 84 | 84 | |
| 85 | - // set pager |
|
| 86 | - $this->pageSize = $pageSize; |
|
| 87 | - $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
| 88 | - $this->pagerLocation = 'top-right'; |
|
| 89 | - } |
|
| 85 | + // set pager |
|
| 86 | + $this->pageSize = $pageSize; |
|
| 87 | + $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
| 88 | + $this->pagerLocation = 'top-right'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | public function setDataSource($ds) { |
| 92 | - $this->ds = $ds; |
|
| 93 | - } |
|
| 92 | + $this->ds = $ds; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | public function render() { |
| 96 | 96 | $modx = evolutionCMS(); |
| 97 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
| 98 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
| 99 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
| 100 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
| 101 | - |
|
| 102 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
| 103 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
| 104 | - |
|
| 105 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
| 106 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
| 107 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
| 108 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
| 109 | - |
|
| 110 | - $this->_alt = 0; |
|
| 111 | - $this->_total = 0; |
|
| 112 | - |
|
| 113 | - $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
| 114 | - |
|
| 115 | - if(!$cssStyle && !$cssClass) { |
|
| 116 | - $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
| 117 | - } |
|
| 118 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
| 119 | - $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
| 120 | - } |
|
| 121 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
| 122 | - $this->_itemStyle = "style='color:black;'"; |
|
| 123 | - } |
|
| 124 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
| 125 | - $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if($this->_isDataset && !$this->columns) { |
|
| 129 | - $cols = $modx->db->numFields($this->ds); |
|
| 130 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // start grid |
|
| 134 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
| 135 | - $tblEnd = "</table>"; |
|
| 136 | - |
|
| 137 | - // build column header |
|
| 138 | - $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
| 139 | - $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
| 140 | - $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
| 141 | - $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
| 142 | - $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
| 143 | - $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
| 144 | - $this->_colcount = count($this->_colnames); |
|
| 145 | - if(!$this->_isDataset) { |
|
| 146 | - $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
| 147 | - $this->ds = array_chunk($this->ds, $this->_colcount); |
|
| 148 | - } |
|
| 149 | - $tblColHdr = "<thead><tr>"; |
|
| 150 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
| 151 | - $name = $this->_colnames[$c]; |
|
| 152 | - $width = $this->_colwidths[$c]; |
|
| 153 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
| 154 | - } |
|
| 155 | - $tblColHdr .= "</tr></thead>\n"; |
|
| 156 | - |
|
| 157 | - // build rows |
|
| 158 | - $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 159 | - $this->_fieldnames = explode(",", $this->fields); |
|
| 160 | - if($rowcount == 0) { |
|
| 161 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
| 162 | - } else { |
|
| 163 | - // render grid items |
|
| 164 | - if($this->pageSize <= 0) { |
|
| 165 | - for($r = 0; $r < $rowcount; $r++) { |
|
| 166 | - $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
| 167 | - $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
| 168 | - } |
|
| 169 | - } else { |
|
| 170 | - if(!$this->pager) { |
|
| 171 | - include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
| 172 | - $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
| 173 | - $this->pager->setRenderRowFnc($this); // pass this object |
|
| 174 | - $this->pager->cssStyle = $pagerStyle; |
|
| 175 | - $this->pager->cssClass = $pagerClass; |
|
| 176 | - } else { |
|
| 177 | - $this->pager->pageSize = $this->pageSize; |
|
| 178 | - $this->pager->pageNumber = $this->pageNumber; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $this->pager->render(); |
|
| 182 | - $tblRows = $this->pager->getRenderedRows(); |
|
| 183 | - $tblPager = $this->pager->getRenderedPager(); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // setup header,pager and footer |
|
| 188 | - $o = $tblStart; |
|
| 189 | - $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 190 | - $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 191 | - if($this->header) { |
|
| 192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
| 193 | - } |
|
| 194 | - if($tblPager && $ptop) { |
|
| 195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
| 196 | - } |
|
| 197 | - $o .= $tblColHdr . $tblRows; |
|
| 198 | - if($tblPager && $pbot) { |
|
| 199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
| 200 | - } |
|
| 201 | - if($this->footer) { |
|
| 202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
| 203 | - } |
|
| 204 | - $o .= $tblEnd; |
|
| 205 | - return $o; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - // format column values |
|
| 97 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
| 98 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
| 99 | + $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
| 100 | + $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
| 101 | + |
|
| 102 | + $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
| 103 | + $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
| 104 | + |
|
| 105 | + $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
| 106 | + $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
| 107 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
| 108 | + $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
| 109 | + |
|
| 110 | + $this->_alt = 0; |
|
| 111 | + $this->_total = 0; |
|
| 112 | + |
|
| 113 | + $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array |
|
| 114 | + |
|
| 115 | + if(!$cssStyle && !$cssClass) { |
|
| 116 | + $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
| 117 | + } |
|
| 118 | + if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
| 119 | + $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
| 120 | + } |
|
| 121 | + if(!$this->_itemStyle && !$this->_itemClass) { |
|
| 122 | + $this->_itemStyle = "style='color:black;'"; |
|
| 123 | + } |
|
| 124 | + if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
| 125 | + $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if($this->_isDataset && !$this->columns) { |
|
| 129 | + $cols = $modx->db->numFields($this->ds); |
|
| 130 | + for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // start grid |
|
| 134 | + $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
| 135 | + $tblEnd = "</table>"; |
|
| 136 | + |
|
| 137 | + // build column header |
|
| 138 | + $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
| 139 | + $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
| 140 | + $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
| 141 | + $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
| 142 | + $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
| 143 | + $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
| 144 | + $this->_colcount = count($this->_colnames); |
|
| 145 | + if(!$this->_isDataset) { |
|
| 146 | + $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
| 147 | + $this->ds = array_chunk($this->ds, $this->_colcount); |
|
| 148 | + } |
|
| 149 | + $tblColHdr = "<thead><tr>"; |
|
| 150 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
| 151 | + $name = $this->_colnames[$c]; |
|
| 152 | + $width = $this->_colwidths[$c]; |
|
| 153 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
| 154 | + } |
|
| 155 | + $tblColHdr .= "</tr></thead>\n"; |
|
| 156 | + |
|
| 157 | + // build rows |
|
| 158 | + $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 159 | + $this->_fieldnames = explode(",", $this->fields); |
|
| 160 | + if($rowcount == 0) { |
|
| 161 | + $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
| 162 | + } else { |
|
| 163 | + // render grid items |
|
| 164 | + if($this->pageSize <= 0) { |
|
| 165 | + for($r = 0; $r < $rowcount; $r++) { |
|
| 166 | + $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r]; |
|
| 167 | + $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
| 168 | + } |
|
| 169 | + } else { |
|
| 170 | + if(!$this->pager) { |
|
| 171 | + include_once dirname(__FILE__) . "/datasetpager.class.php"; |
|
| 172 | + $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
| 173 | + $this->pager->setRenderRowFnc($this); // pass this object |
|
| 174 | + $this->pager->cssStyle = $pagerStyle; |
|
| 175 | + $this->pager->cssClass = $pagerClass; |
|
| 176 | + } else { |
|
| 177 | + $this->pager->pageSize = $this->pageSize; |
|
| 178 | + $this->pager->pageNumber = $this->pageNumber; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $this->pager->render(); |
|
| 182 | + $tblRows = $this->pager->getRenderedRows(); |
|
| 183 | + $tblPager = $this->pager->getRenderedPager(); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // setup header,pager and footer |
|
| 188 | + $o = $tblStart; |
|
| 189 | + $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 190 | + $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
| 191 | + if($this->header) { |
|
| 192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
| 193 | + } |
|
| 194 | + if($tblPager && $ptop) { |
|
| 195 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
| 196 | + } |
|
| 197 | + $o .= $tblColHdr . $tblRows; |
|
| 198 | + if($tblPager && $pbot) { |
|
| 199 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
| 200 | + } |
|
| 201 | + if($this->footer) { |
|
| 202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
| 203 | + } |
|
| 204 | + $o .= $tblEnd; |
|
| 205 | + return $o; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + // format column values |
|
| 209 | 209 | |
| 210 | 210 | public function RenderRowFnc($n, $row) { |
| 211 | - if($this->_alt == 0) { |
|
| 212 | - $Style = $this->_itemStyle; |
|
| 213 | - $Class = $this->_itemClass; |
|
| 214 | - $this->_alt = 1; |
|
| 215 | - } else { |
|
| 216 | - $Style = $this->_altItemStyle; |
|
| 217 | - $Class = $this->_altItemClass; |
|
| 218 | - $this->_alt = 0; |
|
| 219 | - } |
|
| 220 | - $o = "<tr>"; |
|
| 221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
| 222 | - $colStyle = $Style; |
|
| 223 | - $fld = trim($this->_fieldnames[$c]); |
|
| 224 | - $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
| 225 | - $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
| 226 | - $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
| 227 | - $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
| 228 | - $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
| 229 | - $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
| 230 | - if($color && $Style) { |
|
| 231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
| 232 | - } |
|
| 233 | - $value = $this->formatColumnValue($row, $value, $type, $align); |
|
| 234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
| 235 | - } |
|
| 236 | - $o .= "</tr>\n"; |
|
| 237 | - return $o; |
|
| 238 | - } |
|
| 211 | + if($this->_alt == 0) { |
|
| 212 | + $Style = $this->_itemStyle; |
|
| 213 | + $Class = $this->_itemClass; |
|
| 214 | + $this->_alt = 1; |
|
| 215 | + } else { |
|
| 216 | + $Style = $this->_altItemStyle; |
|
| 217 | + $Class = $this->_altItemClass; |
|
| 218 | + $this->_alt = 0; |
|
| 219 | + } |
|
| 220 | + $o = "<tr>"; |
|
| 221 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
| 222 | + $colStyle = $Style; |
|
| 223 | + $fld = trim($this->_fieldnames[$c]); |
|
| 224 | + $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
| 225 | + $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
| 226 | + $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
| 227 | + $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
| 228 | + $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
| 229 | + $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
| 230 | + if($color && $Style) { |
|
| 231 | + $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
| 232 | + } |
|
| 233 | + $value = $this->formatColumnValue($row, $value, $type, $align); |
|
| 234 | + $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
| 235 | + } |
|
| 236 | + $o .= "</tr>\n"; |
|
| 237 | + return $o; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | public function formatColumnValue($row, $value, $type, &$align) { |
| 241 | - if(strpos($type, ":") !== false) { |
|
| 242 | - list($type, $type_format) = explode(":", $type, 2); |
|
| 243 | - } |
|
| 244 | - switch(strtolower($type)) { |
|
| 245 | - case "integer": |
|
| 246 | - if($align == "") { |
|
| 247 | - $align = "right"; |
|
| 248 | - } |
|
| 249 | - $value = number_format($value); |
|
| 250 | - break; |
|
| 251 | - |
|
| 252 | - case "float": |
|
| 253 | - if($align == "") { |
|
| 254 | - $align = "right"; |
|
| 255 | - } |
|
| 256 | - if(!$type_format) { |
|
| 257 | - $type_format = 2; |
|
| 258 | - } |
|
| 259 | - $value = number_format($value, $type_format); |
|
| 260 | - break; |
|
| 261 | - |
|
| 262 | - case "currency": |
|
| 263 | - if($align == "") { |
|
| 264 | - $align = "right"; |
|
| 265 | - } |
|
| 266 | - if(!$type_format) { |
|
| 267 | - $type_format = 2; |
|
| 268 | - } |
|
| 269 | - $value = "$" . number_format($value, $type_format); |
|
| 270 | - break; |
|
| 271 | - |
|
| 272 | - case "date": |
|
| 273 | - if($align == "") { |
|
| 274 | - $align = "right"; |
|
| 275 | - } |
|
| 276 | - if(!is_numeric($value)) { |
|
| 277 | - $value = strtotime($value); |
|
| 278 | - } |
|
| 279 | - if(!$type_format) { |
|
| 280 | - $type_format = "%A %d, %B %Y"; |
|
| 281 | - } |
|
| 282 | - $value = strftime($type_format, $value); |
|
| 283 | - break; |
|
| 284 | - |
|
| 285 | - case "boolean": |
|
| 286 | - if($align == '') { |
|
| 287 | - $align = "center"; |
|
| 288 | - } |
|
| 289 | - $value = number_format($value); |
|
| 290 | - if($value) { |
|
| 291 | - $value = '•'; |
|
| 292 | - } else { |
|
| 293 | - $value = ' '; |
|
| 294 | - } |
|
| 295 | - break; |
|
| 296 | - |
|
| 297 | - case "template": |
|
| 298 | - // replace [+value+] first |
|
| 299 | - $value = str_replace("[+value+]", $value, $type_format); |
|
| 300 | - // replace other [+fields+] |
|
| 301 | - if(strpos($value, "[+") !== false) { |
|
| 302 | - foreach($row as $k => $v) { |
|
| 303 | - $value = str_replace("[+$k+]", $v, $value); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - break; |
|
| 307 | - |
|
| 308 | - } |
|
| 309 | - return $value; |
|
| 310 | - } |
|
| 241 | + if(strpos($type, ":") !== false) { |
|
| 242 | + list($type, $type_format) = explode(":", $type, 2); |
|
| 243 | + } |
|
| 244 | + switch(strtolower($type)) { |
|
| 245 | + case "integer": |
|
| 246 | + if($align == "") { |
|
| 247 | + $align = "right"; |
|
| 248 | + } |
|
| 249 | + $value = number_format($value); |
|
| 250 | + break; |
|
| 251 | + |
|
| 252 | + case "float": |
|
| 253 | + if($align == "") { |
|
| 254 | + $align = "right"; |
|
| 255 | + } |
|
| 256 | + if(!$type_format) { |
|
| 257 | + $type_format = 2; |
|
| 258 | + } |
|
| 259 | + $value = number_format($value, $type_format); |
|
| 260 | + break; |
|
| 261 | + |
|
| 262 | + case "currency": |
|
| 263 | + if($align == "") { |
|
| 264 | + $align = "right"; |
|
| 265 | + } |
|
| 266 | + if(!$type_format) { |
|
| 267 | + $type_format = 2; |
|
| 268 | + } |
|
| 269 | + $value = "$" . number_format($value, $type_format); |
|
| 270 | + break; |
|
| 271 | + |
|
| 272 | + case "date": |
|
| 273 | + if($align == "") { |
|
| 274 | + $align = "right"; |
|
| 275 | + } |
|
| 276 | + if(!is_numeric($value)) { |
|
| 277 | + $value = strtotime($value); |
|
| 278 | + } |
|
| 279 | + if(!$type_format) { |
|
| 280 | + $type_format = "%A %d, %B %Y"; |
|
| 281 | + } |
|
| 282 | + $value = strftime($type_format, $value); |
|
| 283 | + break; |
|
| 284 | + |
|
| 285 | + case "boolean": |
|
| 286 | + if($align == '') { |
|
| 287 | + $align = "center"; |
|
| 288 | + } |
|
| 289 | + $value = number_format($value); |
|
| 290 | + if($value) { |
|
| 291 | + $value = '•'; |
|
| 292 | + } else { |
|
| 293 | + $value = ' '; |
|
| 294 | + } |
|
| 295 | + break; |
|
| 296 | + |
|
| 297 | + case "template": |
|
| 298 | + // replace [+value+] first |
|
| 299 | + $value = str_replace("[+value+]", $value, $type_format); |
|
| 300 | + // replace other [+fields+] |
|
| 301 | + if(strpos($value, "[+") !== false) { |
|
| 302 | + foreach($row as $k => $v) { |
|
| 303 | + $value = str_replace("[+$k+]", $v, $value); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + break; |
|
| 307 | + |
|
| 308 | + } |
|
| 309 | + return $value; |
|
| 310 | + } |
|
| 311 | 311 | } |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DataSetPager { |
| 14 | 14 | |
| 15 | - public $ds; // datasource |
|
| 15 | + public $ds; // datasource |
|
| 16 | 16 | public $pageSize; |
| 17 | 17 | public $pageNumber; |
| 18 | 18 | public $rows; |
| 19 | 19 | public $pager; |
| 20 | 20 | public $id; |
| 21 | 21 | |
| 22 | - // normal page |
|
| 22 | + // normal page |
|
| 23 | 23 | public $pageStyle; |
| 24 | 24 | public $pageClass; |
| 25 | 25 | |
| 26 | - // selected page |
|
| 26 | + // selected page |
|
| 27 | 27 | public $selPageStyle; |
| 28 | 28 | public $selPageClass; |
| 29 | 29 | public $renderRowFnc; |
@@ -32,166 +32,166 @@ discard block |
||
| 32 | 32 | public $renderPagerFncArgs; |
| 33 | 33 | |
| 34 | 34 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
| 35 | - global $_PAGE; // use view state object |
|
| 36 | - |
|
| 37 | - global $__DataSetPagerCnt; |
|
| 38 | - |
|
| 39 | - // set id |
|
| 40 | - $__DataSetPagerCnt++; |
|
| 41 | - $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | - |
|
| 43 | - // get pagenumber |
|
| 44 | - // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | - if($pageNumber == -1) { |
|
| 46 | - $pageNumber = 1; |
|
| 47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - if(!is_numeric($pageNumber)) { |
|
| 54 | - $pageNumber = 1; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $this->ds = $ds; // datasource |
|
| 58 | - $this->pageSize = $pageSize; |
|
| 59 | - $this->pageNumber = $pageNumber; |
|
| 60 | - $this->rows = ''; |
|
| 61 | - $this->pager = ''; |
|
| 62 | - } |
|
| 35 | + global $_PAGE; // use view state object |
|
| 36 | + |
|
| 37 | + global $__DataSetPagerCnt; |
|
| 38 | + |
|
| 39 | + // set id |
|
| 40 | + $__DataSetPagerCnt++; |
|
| 41 | + $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt; |
|
| 42 | + |
|
| 43 | + // get pagenumber |
|
| 44 | + // by setting pager to -1 cause pager to load it's last page number |
|
| 45 | + if($pageNumber == -1) { |
|
| 46 | + $pageNumber = 1; |
|
| 47 | + if(isset($_GET["dpgn" . $this->id])) { |
|
| 48 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
| 49 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
| 50 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + if(!is_numeric($pageNumber)) { |
|
| 54 | + $pageNumber = 1; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $this->ds = $ds; // datasource |
|
| 58 | + $this->pageSize = $pageSize; |
|
| 59 | + $this->pageNumber = $pageNumber; |
|
| 60 | + $this->rows = ''; |
|
| 61 | + $this->pager = ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | public function getRenderedPager() { |
| 65 | - return $this->pager; |
|
| 66 | - } |
|
| 65 | + return $this->pager; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | public function getRenderedRows() { |
| 69 | - return $this->rows; |
|
| 70 | - } |
|
| 69 | + return $this->rows; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | public function setDataSource($ds) { |
| 73 | - $this->ds = $ds; |
|
| 74 | - } |
|
| 73 | + $this->ds = $ds; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | public function setPageSize($ps) { |
| 77 | - $this->pageSize = $ps; |
|
| 78 | - } |
|
| 77 | + $this->pageSize = $ps; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | public function setRenderRowFnc($fncName, $args = "") { |
| 81 | - $this->renderRowFnc = &$fncName; |
|
| 82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
| 81 | + $this->renderRowFnc = &$fncName; |
|
| 82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | public function setRenderPagerFnc($fncName, $args = "") { |
| 88 | - $this->renderPagerFnc = $fncName; |
|
| 89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | - } |
|
| 88 | + $this->renderPagerFnc = $fncName; |
|
| 89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | public function render() { |
| 93 | - $modx = evolutionCMS(); global $_PAGE; |
|
| 94 | - |
|
| 95 | - $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | - |
|
| 97 | - if(!$this->selPageStyle) { |
|
| 98 | - $this->selPageStyle = "font-weight:bold"; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // get total number of rows |
|
| 102 | - $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | - |
|
| 104 | - // render: no records found |
|
| 105 | - if($tnr <= 0) { |
|
| 106 | - $fnc = $this->renderRowFnc; |
|
| 107 | - $args = $this->renderRowFncArgs; |
|
| 108 | - if(isset($fnc)) { |
|
| 109 | - if($args != "") { |
|
| 110 | - $this->rows .= $fnc(0, null, $args); |
|
| 111 | - } // if agrs was specified then we will pass three params |
|
| 112 | - else { |
|
| 113 | - $this->rows .= $fnc(0, null); |
|
| 114 | - } // otherwise two will be passed |
|
| 115 | - } |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // get total pages |
|
| 120 | - $tp = ceil($tnr / $this->pageSize); |
|
| 121 | - if($this->pageNumber > $tp) { |
|
| 122 | - $this->pageNumber = 1; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // get page number |
|
| 126 | - $p = $this->pageNumber; |
|
| 127 | - |
|
| 128 | - // save page number to view state if available |
|
| 129 | - if(isset($_PAGE['vs'])) { |
|
| 130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | - if($tp > 1) { |
|
| 135 | - $url = ''; |
|
| 136 | - $fnc = $this->renderPagerFnc; |
|
| 137 | - $args = $this->renderPagerFncArgs; |
|
| 138 | - if(!isset($fnc)) { |
|
| 139 | - if($modx->isFrontend()) { |
|
| 140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | - } else { |
|
| 142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | - } |
|
| 144 | - $i = 0; |
|
| 145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | - $i++; |
|
| 147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | - } |
|
| 149 | - if($i >= 1) { |
|
| 150 | - $url .= "&"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - for($i = 1; $i <= $tp; $i++) { |
|
| 154 | - if(isset($fnc)) { |
|
| 155 | - if($args != "") { |
|
| 156 | - $this->pager .= $fnc($p, $i, $args); |
|
| 157 | - } else { |
|
| 158 | - $this->pager .= $fnc($p, $i); |
|
| 159 | - } |
|
| 160 | - } else { |
|
| 161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | - $fnc = $this->renderRowFnc; |
|
| 168 | - $args = $this->renderRowFncArgs; |
|
| 169 | - |
|
| 170 | - if(isset($fnc)) { |
|
| 171 | - $i = 1; |
|
| 172 | - $fncObject = is_object($fnc); |
|
| 173 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | - if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | - if($fncObject) { |
|
| 178 | - if($args != "") { |
|
| 179 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | - } else { |
|
| 181 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | - } |
|
| 183 | - } else { |
|
| 184 | - if($args != "") { |
|
| 185 | - $this->rows .= $fnc($i, $row, $args); |
|
| 186 | - } // if agrs was specified then we wil pass three params |
|
| 187 | - else { |
|
| 188 | - $this->rows .= $fnc($i, $row); |
|
| 189 | - } // otherwise two will be passed |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - } |
|
| 193 | - $i++; |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 93 | + $modx = evolutionCMS(); global $_PAGE; |
|
| 94 | + |
|
| 95 | + $isDataset = $modx->db->isResult($this->ds); |
|
| 96 | + |
|
| 97 | + if(!$this->selPageStyle) { |
|
| 98 | + $this->selPageStyle = "font-weight:bold"; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // get total number of rows |
|
| 102 | + $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds); |
|
| 103 | + |
|
| 104 | + // render: no records found |
|
| 105 | + if($tnr <= 0) { |
|
| 106 | + $fnc = $this->renderRowFnc; |
|
| 107 | + $args = $this->renderRowFncArgs; |
|
| 108 | + if(isset($fnc)) { |
|
| 109 | + if($args != "") { |
|
| 110 | + $this->rows .= $fnc(0, null, $args); |
|
| 111 | + } // if agrs was specified then we will pass three params |
|
| 112 | + else { |
|
| 113 | + $this->rows .= $fnc(0, null); |
|
| 114 | + } // otherwise two will be passed |
|
| 115 | + } |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // get total pages |
|
| 120 | + $tp = ceil($tnr / $this->pageSize); |
|
| 121 | + if($this->pageNumber > $tp) { |
|
| 122 | + $this->pageNumber = 1; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // get page number |
|
| 126 | + $p = $this->pageNumber; |
|
| 127 | + |
|
| 128 | + // save page number to view state if available |
|
| 129 | + if(isset($_PAGE['vs'])) { |
|
| 130 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
| 134 | + if($tp > 1) { |
|
| 135 | + $url = ''; |
|
| 136 | + $fnc = $this->renderPagerFnc; |
|
| 137 | + $args = $this->renderPagerFncArgs; |
|
| 138 | + if(!isset($fnc)) { |
|
| 139 | + if($modx->isFrontend()) { |
|
| 140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
| 141 | + } else { |
|
| 142 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
| 143 | + } |
|
| 144 | + $i = 0; |
|
| 145 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
| 146 | + $i++; |
|
| 147 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
| 148 | + } |
|
| 149 | + if($i >= 1) { |
|
| 150 | + $url .= "&"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + for($i = 1; $i <= $tp; $i++) { |
|
| 154 | + if(isset($fnc)) { |
|
| 155 | + if($args != "") { |
|
| 156 | + $this->pager .= $fnc($p, $i, $args); |
|
| 157 | + } else { |
|
| 158 | + $this->pager .= $fnc($p, $i); |
|
| 159 | + } |
|
| 160 | + } else { |
|
| 161 | + $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
| 167 | + $fnc = $this->renderRowFnc; |
|
| 168 | + $args = $this->renderRowFncArgs; |
|
| 169 | + |
|
| 170 | + if(isset($fnc)) { |
|
| 171 | + $i = 1; |
|
| 172 | + $fncObject = is_object($fnc); |
|
| 173 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
| 174 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
| 175 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) { |
|
| 176 | + if($i >= $minitems && $i <= $maxitems) { |
|
| 177 | + if($fncObject) { |
|
| 178 | + if($args != "") { |
|
| 179 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
| 180 | + } else { |
|
| 181 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
| 182 | + } |
|
| 183 | + } else { |
|
| 184 | + if($args != "") { |
|
| 185 | + $this->rows .= $fnc($i, $row, $args); |
|
| 186 | + } // if agrs was specified then we wil pass three params |
|
| 187 | + else { |
|
| 188 | + $this->rows .= $fnc($i, $row); |
|
| 189 | + } // otherwise two will be passed |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + } |
|
| 193 | + $i++; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function ProcessFile($file) { |
| 133 | 133 | // get the file |
| 134 | - $buffer = @file_get_contents($file); |
|
| 135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 134 | + $buffer = @file_get_contents($file); |
|
| 135 | + if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
| 136 | 136 | return $buffer; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | function parseTvValues($param, $tvsArray) |
| 169 | 169 | { |
| 170 | 170 | $modx = evolutionCMS(); |
| 171 | - $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | - if (strpos($param, '[*') !== false) { |
|
| 173 | - $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | - foreach ($matches[0] as $i=>$match) { |
|
| 175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | - $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | - $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | - } else { |
|
| 180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | - } |
|
| 182 | - $param = str_replace($match, $value, $param); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - return $param; |
|
| 171 | + $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
| 172 | + if (strpos($param, '[*') !== false) { |
|
| 173 | + $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
| 174 | + foreach ($matches[0] as $i=>$match) { |
|
| 175 | + if(isset($tvsArray[ $matches[1][$i] ])) { |
|
| 176 | + if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
| 177 | + $value = $tvsArray[$matches[1][$i]]['value']; |
|
| 178 | + $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
| 179 | + } else { |
|
| 180 | + $value = $tvsArray[ $matches[1][$i] ]; |
|
| 181 | + } |
|
| 182 | + $param = str_replace($match, $value, $param); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + return $param; |
|
| 187 | 187 | } |
@@ -10,178 +10,178 @@ |
||
| 10 | 10 | Class TemplateParser {
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * @param array $config [action, tabs, toArray] |
|
| 14 | - * @param array $data |
|
| 15 | - * @return string |
|
| 16 | - */ |
|
| 17 | - public function output($config = array(), $data = array()) {
|
|
| 13 | + * @param array $config [action, tabs, toArray] |
|
| 14 | + * @param array $data |
|
| 15 | + * @return string |
|
| 16 | + */ |
|
| 17 | + public function output($config = array(), $data = array()) {
|
|
| 18 | 18 | $modx = evolutionCMS(); |
| 19 | 19 | |
| 20 | - $output = ''; |
|
| 21 | - $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
| 22 | - $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
|
| 20 | + $output = ''; |
|
| 21 | + $action = !empty($config['action']) ? $config['action'] : (!empty($_REQUEST['a']) ? $_REQUEST['a'] : ''); |
|
| 22 | + $tab = isset($config['tab']) ? ' AND tab IN(' . $config['tab'] . ')' : '';
|
|
| 23 | 23 | |
| 24 | - if($action) {
|
|
| 25 | - $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
|
| 24 | + if($action) {
|
|
| 25 | + $sql = $modx->db->query('SELECT t1.*, IF(t1.alias=\'\',t1.name,t1.alias) AS alias, t2.category AS category_name
|
|
| 26 | 26 | FROM ' . $modx->getFullTableName('system_templates') . ' AS t1
|
| 27 | 27 | INNER JOIN ' . $modx->getFullTableName('categories') . ' AS t2 ON t2.id=t1.category
|
| 28 | 28 | WHERE t1.action IN(' . $action . ') ' . $tab . '
|
| 29 | 29 | ORDER BY t1.tab ASC, t1.rank ASC'); |
| 30 | 30 | |
| 31 | - if($modx->db->getRecordCount($sql)) {
|
|
| 32 | - $tabs = array(); |
|
| 33 | - while($row = $modx->db->getRow($sql)) {
|
|
| 34 | - if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | - $row['value'] = $data[$row['name']]; |
|
| 36 | - } |
|
| 37 | - $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
| 38 | - $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if(!empty($config['toArray'])) {
|
|
| 42 | - $output = $tabs; |
|
| 43 | - } else {
|
|
| 44 | - $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 45 | - $output .= ' |
|
| 31 | + if($modx->db->getRecordCount($sql)) {
|
|
| 32 | + $tabs = array(); |
|
| 33 | + while($row = $modx->db->getRow($sql)) {
|
|
| 34 | + if(!$row['value'] && !empty($data[$row['name']])) {
|
|
| 35 | + $row['value'] = $data[$row['name']]; |
|
| 36 | + } |
|
| 37 | + $tabs[$row['tab']]['category_name'] = $row['category_name']; |
|
| 38 | + $tabs[$row['tab']][$row['name']] = TemplateParser::render($row); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if(!empty($config['toArray'])) {
|
|
| 42 | + $output = $tabs; |
|
| 43 | + } else {
|
|
| 44 | + $output .= '<div class="tab-pane" id="pane_' . $action . '">'; |
|
| 45 | + $output .= ' |
|
| 46 | 46 | <script type="text/javascript"> |
| 47 | 47 | var pane_' . $action . ' = new WebFXTabPane(document.getElementById("pane_' . $action . '"), ' . ($modx->config['remember_last_tab'] == 1 ? 'true' : 'false') . ');
|
| 48 | 48 | </script>'; |
| 49 | 49 | |
| 50 | - foreach($tabs as $idTab => $tab) {
|
|
| 51 | - $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 52 | - $output .= ' |
|
| 50 | + foreach($tabs as $idTab => $tab) {
|
|
| 51 | + $output .= '<div class="tab-page" id="tab_' . $action . '_' . $idTab . '">'; |
|
| 52 | + $output .= ' |
|
| 53 | 53 | <h2 class="tab">' . (!empty($config['tabs'][$idTab]) ? $config['tabs'][$idTab] : $tab['category_name']) . '</h2> |
| 54 | 54 | <script type="text/javascript">pane_' . $action . '.addTabPage(document.getElementById("tab_' . $action . '_' . $idTab . '"));</script>';
|
| 55 | - unset($tab['category_name']); |
|
| 56 | - foreach($tab as $item) {
|
|
| 57 | - $output .= $item; |
|
| 58 | - } |
|
| 59 | - $output .= '</div>'; |
|
| 60 | - } |
|
| 61 | - $output .= '</div>'; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - return $output; |
|
| 67 | - } |
|
| 55 | + unset($tab['category_name']); |
|
| 56 | + foreach($tab as $item) {
|
|
| 57 | + $output .= $item; |
|
| 58 | + } |
|
| 59 | + $output .= '</div>'; |
|
| 60 | + } |
|
| 61 | + $output .= '</div>'; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + return $output; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param array $data |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | - private function render($data) {
|
|
| 74 | - $modx = evolutionCMS(); global $_lang, $_country_lang; |
|
| 73 | + private function render($data) {
|
|
| 74 | + $modx = evolutionCMS(); global $_lang, $_country_lang; |
|
| 75 | 75 | |
| 76 | - $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
| 77 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
| 78 | - $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
| 76 | + $data['lang.name'] = (isset($_lang[$data['alias']]) ? $_lang[$data['alias']] : $data['alias']); |
|
| 77 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $_POST[$data['name']][$data['value']] : (isset($data['value']) ? $modx->htmlspecialchars($data['value']) : '')); |
|
| 78 | + $data['readonly'] = ($data['readonly'] ? ' readonly' : ''); |
|
| 79 | 79 | |
| 80 | - $output = ''; |
|
| 81 | - $output .= '<div class="form-group row">'; |
|
| 80 | + $output = ''; |
|
| 81 | + $output .= '<div class="form-group row">'; |
|
| 82 | 82 | |
| 83 | - switch($data['type']) {
|
|
| 83 | + switch($data['type']) {
|
|
| 84 | 84 | |
| 85 | - case 'text': |
|
| 86 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 85 | + case 'text': |
|
| 86 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 87 | 87 | <div class="col-sm-7"> |
| 88 | 88 | <input type="text" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 89 | - $output .= $data['content']; |
|
| 90 | - $output .= '</div>'; |
|
| 89 | + $output .= $data['content']; |
|
| 90 | + $output .= '</div>'; |
|
| 91 | 91 | |
| 92 | - break; |
|
| 92 | + break; |
|
| 93 | 93 | |
| 94 | - case 'textarea': |
|
| 95 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 94 | + case 'textarea': |
|
| 95 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 96 | 96 | <div class="col-sm-7"> |
| 97 | 97 | <textarea name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;"[+readonly+]>[+value+]</textarea>'; |
| 98 | - $output .= $data['content']; |
|
| 99 | - $output .= '</div>'; |
|
| 98 | + $output .= $data['content']; |
|
| 99 | + $output .= '</div>'; |
|
| 100 | 100 | |
| 101 | - break; |
|
| 101 | + break; |
|
| 102 | 102 | |
| 103 | - case 'date': |
|
| 104 | - $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
| 105 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 103 | + case 'date': |
|
| 104 | + $data['value'] = (isset($_POST[$data['name']][$data['value']]) ? $modx->toDateFormat($_POST[$data['name']][$data['value']]) : (isset($data['value']) ? $modx->toDateFormat($data['value']) : '')); |
|
| 105 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label> |
|
| 106 | 106 | <div class="col-sm-7"> |
| 107 | 107 | <input type="text" name="[+name+]" class="form-control DatePicker" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
| 108 | - $output .= $data['content']; |
|
| 109 | - $output .= '</div>'; |
|
| 110 | - |
|
| 111 | - break; |
|
| 112 | - |
|
| 113 | - case 'select': |
|
| 114 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 115 | - $output .= '<div class="col-sm-7">'; |
|
| 116 | - $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
| 117 | - if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 118 | - $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
| 119 | - $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 120 | - foreach($_country_lang as $key => $value) {
|
|
| 121 | - $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 122 | - } |
|
| 123 | - } else {
|
|
| 124 | - if($data['elements']) {
|
|
| 125 | - $elements = explode('||', $data['elements']);
|
|
| 126 | - foreach($elements as $key => $value) {
|
|
| 127 | - $value = explode('==', $value);
|
|
| 128 | - $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - $output .= '</select>'; |
|
| 133 | - $output .= $data['content']; |
|
| 134 | - $output .= '</div>'; |
|
| 135 | - |
|
| 136 | - break; |
|
| 137 | - |
|
| 138 | - case 'checkbox': |
|
| 139 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 140 | - $output .= '<div class="col-sm-7">'; |
|
| 141 | - $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 142 | - if($data['elements']) {
|
|
| 143 | - $elements = explode('||', $data['elements']);
|
|
| 144 | - foreach($elements as $key => $value) {
|
|
| 145 | - $value = explode('==', $value);
|
|
| 146 | - $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $output .= $data['content']; |
|
| 150 | - $output .= '</div>'; |
|
| 151 | - |
|
| 152 | - break; |
|
| 153 | - |
|
| 154 | - case 'radio': |
|
| 155 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 156 | - $output .= '<div class="col-sm-7">'; |
|
| 157 | - $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 158 | - if($data['elements']) {
|
|
| 159 | - $elements = explode('||', $data['elements']);
|
|
| 160 | - foreach($elements as $key => $value) {
|
|
| 161 | - $value = explode('==', $value);
|
|
| 162 | - $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - $output .= $data['content']; |
|
| 166 | - $output .= '</div>'; |
|
| 167 | - |
|
| 168 | - break; |
|
| 169 | - |
|
| 170 | - case 'custom': |
|
| 171 | - $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 172 | - $output .= '<div class="col-sm-7">'; |
|
| 173 | - $output .= $data['content']; |
|
| 174 | - $output .= '</div>'; |
|
| 175 | - |
|
| 176 | - break; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $output .= '</div>'; |
|
| 180 | - |
|
| 181 | - $output = $modx->parseText($output, $data); |
|
| 182 | - |
|
| 183 | - return $output; |
|
| 184 | - } |
|
| 108 | + $output .= $data['content']; |
|
| 109 | + $output .= '</div>'; |
|
| 110 | + |
|
| 111 | + break; |
|
| 112 | + |
|
| 113 | + case 'select': |
|
| 114 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 115 | + $output .= '<div class="col-sm-7">'; |
|
| 116 | + $output .= '<select name="[+name+]" class="form-control" id="[+name+]" onChange="documentDirty=true;">'; |
|
| 117 | + if($data['name'] == 'country' && isset($_country_lang)) {
|
|
| 118 | + $chosenCountry = isset($_POST['country']) ? $_POST['country'] : $data['country']; |
|
| 119 | + $output .= '<option value=""' . (!isset($chosenCountry) ? ' selected' : '') . '> </option>'; |
|
| 120 | + foreach($_country_lang as $key => $value) {
|
|
| 121 | + $output .= '<option value="' . $key . '"' . (isset($chosenCountry) && $chosenCountry == $key ? ' selected' : '') . '>' . $value . '</option>'; |
|
| 122 | + } |
|
| 123 | + } else {
|
|
| 124 | + if($data['elements']) {
|
|
| 125 | + $elements = explode('||', $data['elements']);
|
|
| 126 | + foreach($elements as $key => $value) {
|
|
| 127 | + $value = explode('==', $value);
|
|
| 128 | + $output .= '<option value="' . $value[1] . '">' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]) . '</option>'; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + $output .= '</select>'; |
|
| 133 | + $output .= $data['content']; |
|
| 134 | + $output .= '</div>'; |
|
| 135 | + |
|
| 136 | + break; |
|
| 137 | + |
|
| 138 | + case 'checkbox': |
|
| 139 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 140 | + $output .= '<div class="col-sm-7">'; |
|
| 141 | + $output .= '<input type="checkbox" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 142 | + if($data['elements']) {
|
|
| 143 | + $elements = explode('||', $data['elements']);
|
|
| 144 | + foreach($elements as $key => $value) {
|
|
| 145 | + $value = explode('==', $value);
|
|
| 146 | + $output .= '<br /><input type="checkbox" name="' . $value[0] . '" class="form-control" id="' . $value[0] . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $output .= $data['content']; |
|
| 150 | + $output .= '</div>'; |
|
| 151 | + |
|
| 152 | + break; |
|
| 153 | + |
|
| 154 | + case 'radio': |
|
| 155 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 156 | + $output .= '<div class="col-sm-7">'; |
|
| 157 | + $output .= '<input type="radio" name="[+name+]" class="form-control" id="[+name+]" value="[+value+]" onChange="documentDirty=true;"[+readonly+] />'; |
|
| 158 | + if($data['elements']) {
|
|
| 159 | + $elements = explode('||', $data['elements']);
|
|
| 160 | + foreach($elements as $key => $value) {
|
|
| 161 | + $value = explode('==', $value);
|
|
| 162 | + $output .= '<br /><input type="radio" name="[+name+]" class="form-control" id="[+name+]_' . $key . '" value="' . $value[1] . '" onChange="documentDirty=true;"[+readonly+] /> ' . (isset($_lang[$value[0]]) ? $_lang[$value[0]] : $value[0]); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + $output .= $data['content']; |
|
| 166 | + $output .= '</div>'; |
|
| 167 | + |
|
| 168 | + break; |
|
| 169 | + |
|
| 170 | + case 'custom': |
|
| 171 | + $output .= '<label class="col-sm-3" for="[+name+]">[+lang.name+]</label>'; |
|
| 172 | + $output .= '<div class="col-sm-7">'; |
|
| 173 | + $output .= $data['content']; |
|
| 174 | + $output .= '</div>'; |
|
| 175 | + |
|
| 176 | + break; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $output .= '</div>'; |
|
| 180 | + |
|
| 181 | + $output = $modx->parseText($output, $data); |
|
| 182 | + |
|
| 183 | + return $output; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
@@ -21,320 +21,320 @@ discard block |
||
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | - $value = ProcessTVCommand($value, $name, $docid); |
|
| 24 | + $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 25 | + $value = ProcessTVCommand($value, $name, $docid); |
|
| 26 | 26 | |
| 27 | - $params = array(); |
|
| 28 | - if($paramstring) { |
|
| 29 | - $cp = explode("&", $paramstring); |
|
| 30 | - foreach($cp as $p => $v) { |
|
| 31 | - $v = trim($v); // trim |
|
| 32 | - $ar = explode("=", $v); |
|
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 34 | - $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 27 | + $params = array(); |
|
| 28 | + if($paramstring) { |
|
| 29 | + $cp = explode("&", $paramstring); |
|
| 30 | + foreach($cp as $p => $v) { |
|
| 31 | + $v = trim($v); // trim |
|
| 32 | + $ar = explode("=", $v); |
|
| 33 | + if(is_array($ar) && count($ar) == 2) { |
|
| 34 | + $params[$ar[0]] = decodeParamValue($ar[1]); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $id = "tv$name"; |
|
| 40 | - switch($format) { |
|
| 41 | - case 'image': |
|
| 42 | - $images = parseInput($value, '||', 'array'); |
|
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 45 | - $image = explode('==', $image); |
|
| 46 | - } |
|
| 47 | - $src = $image[0]; |
|
| 39 | + $id = "tv$name"; |
|
| 40 | + switch($format) { |
|
| 41 | + case 'image': |
|
| 42 | + $images = parseInput($value, '||', 'array'); |
|
| 43 | + foreach($images as $image) { |
|
| 44 | + if(!is_array($image)) { |
|
| 45 | + $image = explode('==', $image); |
|
| 46 | + } |
|
| 47 | + $src = $image[0]; |
|
| 48 | 48 | |
| 49 | - if($src) { |
|
| 50 | - // We have a valid source |
|
| 51 | - $attributes = ''; |
|
| 52 | - $attr = array( |
|
| 53 | - 'class' => $params['class'], |
|
| 54 | - 'src' => $src, |
|
| 55 | - 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | - 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | - 'style' => $params['style'] |
|
| 58 | - ); |
|
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | - $attr['align'] = $params['align']; |
|
| 61 | - } |
|
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 49 | + if($src) { |
|
| 50 | + // We have a valid source |
|
| 51 | + $attributes = ''; |
|
| 52 | + $attr = array( |
|
| 53 | + 'class' => $params['class'], |
|
| 54 | + 'src' => $src, |
|
| 55 | + 'id' => ($params['id'] ? $params['id'] : ''), |
|
| 56 | + 'alt' => $modx->htmlspecialchars($params['alttext']), |
|
| 57 | + 'style' => $params['style'] |
|
| 58 | + ); |
|
| 59 | + if(isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | + $attr['align'] = $params['align']; |
|
| 61 | + } |
|
| 62 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + $attributes .= ' ' . $params['attrib']; |
|
| 64 | 64 | |
| 65 | - // Output the image with attributes |
|
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - break; |
|
| 65 | + // Output the image with attributes |
|
| 66 | + $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + break; |
|
| 70 | 70 | |
| 71 | - case "delim": // display as delimitted list |
|
| 72 | - $value = parseInput($value, "||"); |
|
| 73 | - $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | - if($p == "\\n") { |
|
| 75 | - $p = "\n"; |
|
| 76 | - } |
|
| 77 | - $o = str_replace("||", $p, $value); |
|
| 78 | - break; |
|
| 71 | + case "delim": // display as delimitted list |
|
| 72 | + $value = parseInput($value, "||"); |
|
| 73 | + $p = $params['format'] ? $params['format'] : " "; |
|
| 74 | + if($p == "\\n") { |
|
| 75 | + $p = "\n"; |
|
| 76 | + } |
|
| 77 | + $o = str_replace("||", $p, $value); |
|
| 78 | + break; |
|
| 79 | 79 | |
| 80 | - case "string": |
|
| 81 | - $value = parseInput($value); |
|
| 82 | - $format = strtolower($params['format']); |
|
| 83 | - if($format == 'upper case') { |
|
| 84 | - $o = strtoupper($value); |
|
| 85 | - } else if($format == 'lower case') { |
|
| 86 | - $o = strtolower($value); |
|
| 87 | - } else if($format == 'sentence case') { |
|
| 88 | - $o = ucfirst($value); |
|
| 89 | - } else if($format == 'capitalize') { |
|
| 90 | - $o = ucwords($value); |
|
| 91 | - } else { |
|
| 92 | - $o = $value; |
|
| 93 | - } |
|
| 94 | - break; |
|
| 80 | + case "string": |
|
| 81 | + $value = parseInput($value); |
|
| 82 | + $format = strtolower($params['format']); |
|
| 83 | + if($format == 'upper case') { |
|
| 84 | + $o = strtoupper($value); |
|
| 85 | + } else if($format == 'lower case') { |
|
| 86 | + $o = strtolower($value); |
|
| 87 | + } else if($format == 'sentence case') { |
|
| 88 | + $o = ucfirst($value); |
|
| 89 | + } else if($format == 'capitalize') { |
|
| 90 | + $o = ucwords($value); |
|
| 91 | + } else { |
|
| 92 | + $o = $value; |
|
| 93 | + } |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | - case "date": |
|
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 99 | - $value = 'now'; |
|
| 100 | - } |
|
| 101 | - $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | - $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | - $o = strftime($p, $timestamp); |
|
| 104 | - } else { |
|
| 105 | - $value = ''; |
|
| 106 | - } |
|
| 107 | - break; |
|
| 96 | + case "date": |
|
| 97 | + if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if(empty($value)) { |
|
| 99 | + $value = 'now'; |
|
| 100 | + } |
|
| 101 | + $timestamp = getUnixtimeFromDateString($value); |
|
| 102 | + $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; |
|
| 103 | + $o = strftime($p, $timestamp); |
|
| 104 | + } else { |
|
| 105 | + $value = ''; |
|
| 106 | + } |
|
| 107 | + break; |
|
| 108 | 108 | |
| 109 | - case "hyperlink": |
|
| 110 | - $value = parseInput($value, "||", "array"); |
|
| 111 | - $o = ''; |
|
| 112 | - $countValue = count($value); |
|
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 114 | - list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | - if(!$url) { |
|
| 116 | - $url = $name; |
|
| 117 | - } |
|
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 120 | - $o .= '<br />'; |
|
| 121 | - } |
|
| 122 | - $attributes = ''; |
|
| 123 | - // setup the link attributes |
|
| 124 | - $attr = array( |
|
| 125 | - 'href' => $url, |
|
| 126 | - 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | - 'class' => $params['class'], |
|
| 128 | - 'style' => $params['style'], |
|
| 129 | - 'target' => $params['target'], |
|
| 130 | - ); |
|
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 109 | + case "hyperlink": |
|
| 110 | + $value = parseInput($value, "||", "array"); |
|
| 111 | + $o = ''; |
|
| 112 | + $countValue = count($value); |
|
| 113 | + for($i = 0; $i < $countValue; $i++) { |
|
| 114 | + list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
|
| 115 | + if(!$url) { |
|
| 116 | + $url = $name; |
|
| 117 | + } |
|
| 118 | + if($url) { |
|
| 119 | + if($o) { |
|
| 120 | + $o .= '<br />'; |
|
| 121 | + } |
|
| 122 | + $attributes = ''; |
|
| 123 | + // setup the link attributes |
|
| 124 | + $attr = array( |
|
| 125 | + 'href' => $url, |
|
| 126 | + 'title' => $params['title'] ? $modx->htmlspecialchars($params['title']) : $name, |
|
| 127 | + 'class' => $params['class'], |
|
| 128 | + 'style' => $params['style'], |
|
| 129 | + 'target' => $params['target'], |
|
| 130 | + ); |
|
| 131 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | - // Output the link |
|
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - break; |
|
| 134 | + // Output the link |
|
| 135 | + $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + break; |
|
| 139 | 139 | |
| 140 | - case "htmltag": |
|
| 141 | - $value = parseInput($value, "||", "array"); |
|
| 142 | - $tagid = $params['tagid']; |
|
| 143 | - $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | - $o = ''; |
|
| 145 | - // Loop through a list of tags |
|
| 140 | + case "htmltag": |
|
| 141 | + $value = parseInput($value, "||", "array"); |
|
| 142 | + $tagid = $params['tagid']; |
|
| 143 | + $tagname = ($params['tagname']) ? $params['tagname'] : 'div'; |
|
| 144 | + $o = ''; |
|
| 145 | + // Loop through a list of tags |
|
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 148 | - $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | - if(!$tagvalue) { |
|
| 150 | - continue; |
|
| 151 | - } |
|
| 147 | + for($i = 0; $i < $countValue; $i++) { |
|
| 148 | + $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
|
| 149 | + if(!$tagvalue) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $attributes = ''; |
|
| 154 | - $attr = array( |
|
| 155 | - 'id' => ($tagid ? $tagid : $id), |
|
| 156 | - // 'tv' already added to id |
|
| 157 | - 'class' => $params['class'], |
|
| 158 | - 'style' => $params['style'], |
|
| 159 | - ); |
|
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 153 | + $attributes = ''; |
|
| 154 | + $attr = array( |
|
| 155 | + 'id' => ($tagid ? $tagid : $id), |
|
| 156 | + // 'tv' already added to id |
|
| 157 | + 'class' => $params['class'], |
|
| 158 | + 'style' => $params['style'], |
|
| 159 | + ); |
|
| 160 | + foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | + $attributes .= ' ' . $params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | - // Output the HTML Tag |
|
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | - } |
|
| 166 | - break; |
|
| 163 | + // Output the HTML Tag |
|
| 164 | + $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 165 | + } |
|
| 166 | + break; |
|
| 167 | 167 | |
| 168 | - case "richtext": |
|
| 169 | - $value = parseInput($value); |
|
| 170 | - $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | - $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | - $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | - $o .= $modx->htmlspecialchars($value); |
|
| 175 | - $o .= '</textarea></div>'; |
|
| 176 | - $replace_richtext = array($id); |
|
| 177 | - // setup editors |
|
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | - // invoke OnRichTextEditorInit event |
|
| 180 | - $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | - 'editor' => $richtexteditor, |
|
| 182 | - 'elements' => $replace_richtext, |
|
| 183 | - 'forfrontend' => 1, |
|
| 184 | - 'width' => $w, |
|
| 185 | - 'height' => $h |
|
| 186 | - )); |
|
| 187 | - if(is_array($evtOut)) { |
|
| 188 | - $o .= implode("", $evtOut); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - break; |
|
| 168 | + case "richtext": |
|
| 169 | + $value = parseInput($value); |
|
| 170 | + $w = $params['w'] ? $params['w'] : '100%'; |
|
| 171 | + $h = $params['h'] ? $params['h'] : '400px'; |
|
| 172 | + $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 174 | + $o .= $modx->htmlspecialchars($value); |
|
| 175 | + $o .= '</textarea></div>'; |
|
| 176 | + $replace_richtext = array($id); |
|
| 177 | + // setup editors |
|
| 178 | + if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | + // invoke OnRichTextEditorInit event |
|
| 180 | + $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
|
| 181 | + 'editor' => $richtexteditor, |
|
| 182 | + 'elements' => $replace_richtext, |
|
| 183 | + 'forfrontend' => 1, |
|
| 184 | + 'width' => $w, |
|
| 185 | + 'height' => $h |
|
| 186 | + )); |
|
| 187 | + if(is_array($evtOut)) { |
|
| 188 | + $o .= implode("", $evtOut); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + break; |
|
| 192 | 192 | |
| 193 | - case "unixtime": |
|
| 194 | - $value = parseInput($value); |
|
| 195 | - $o = getUnixtimeFromDateString($value); |
|
| 196 | - break; |
|
| 193 | + case "unixtime": |
|
| 194 | + $value = parseInput($value); |
|
| 195 | + $o = getUnixtimeFromDateString($value); |
|
| 196 | + break; |
|
| 197 | 197 | |
| 198 | - case "viewport": |
|
| 199 | - $value = parseInput($value); |
|
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 202 | - $params['vpid'] = $id; |
|
| 203 | - } |
|
| 204 | - $sTag = "<iframe"; |
|
| 205 | - $eTag = "</iframe>"; |
|
| 206 | - $autoMode = "0"; |
|
| 207 | - $w = $params['width']; |
|
| 208 | - $h = $params['height']; |
|
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 210 | - $w = "100%"; |
|
| 211 | - $h = "100%"; |
|
| 212 | - } |
|
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 216 | - $autoMode = "1"; //width only |
|
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 219 | - } |
|
| 198 | + case "viewport": |
|
| 199 | + $value = parseInput($value); |
|
| 200 | + $id = '_' . time(); |
|
| 201 | + if(!$params['vpid']) { |
|
| 202 | + $params['vpid'] = $id; |
|
| 203 | + } |
|
| 204 | + $sTag = "<iframe"; |
|
| 205 | + $eTag = "</iframe>"; |
|
| 206 | + $autoMode = "0"; |
|
| 207 | + $w = $params['width']; |
|
| 208 | + $h = $params['height']; |
|
| 209 | + if($params['stretch'] == 'Yes') { |
|
| 210 | + $w = "100%"; |
|
| 211 | + $h = "100%"; |
|
| 212 | + } |
|
| 213 | + if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if($params['awidth'] == 'Yes') { |
|
| 216 | + $autoMode = "1"; //width only |
|
| 217 | + } else if($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | - 'name' => 'viewport', |
|
| 223 | - 'version' => '0', |
|
| 224 | - 'plaintext' => false |
|
| 225 | - )); |
|
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 229 | - } |
|
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 232 | - } |
|
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 235 | - } |
|
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | - $o .= ">"; |
|
| 240 | - $o .= $eTag; |
|
| 241 | - break; |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 222 | + 'name' => 'viewport', |
|
| 223 | + 'version' => '0', |
|
| 224 | + 'plaintext' => false |
|
| 225 | + )); |
|
| 226 | + $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | + if($params['class']) { |
|
| 228 | + $o .= " class='" . $params['class'] . "' "; |
|
| 229 | + } |
|
| 230 | + if($params['style']) { |
|
| 231 | + $o .= " style='" . $params['style'] . "' "; |
|
| 232 | + } |
|
| 233 | + if($params['attrib']) { |
|
| 234 | + $o .= $params['attrib'] . " "; |
|
| 235 | + } |
|
| 236 | + $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | + $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 239 | + $o .= ">"; |
|
| 240 | + $o .= $eTag; |
|
| 241 | + break; |
|
| 242 | 242 | |
| 243 | - case "datagrid": |
|
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | - $grd = new DataGrid('', $value); |
|
| 243 | + case "datagrid": |
|
| 244 | + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 245 | + $grd = new DataGrid('', $value); |
|
| 246 | 246 | |
| 247 | - $grd->noRecordMsg = $params['egmsg']; |
|
| 247 | + $grd->noRecordMsg = $params['egmsg']; |
|
| 248 | 248 | |
| 249 | - $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | - $grd->cssClass = $params['tblc']; |
|
| 251 | - $grd->itemClass = $params['itmc']; |
|
| 252 | - $grd->altItemClass = $params['aitmc']; |
|
| 249 | + $grd->columnHeaderClass = $params['chdrc']; |
|
| 250 | + $grd->cssClass = $params['tblc']; |
|
| 251 | + $grd->itemClass = $params['itmc']; |
|
| 252 | + $grd->altItemClass = $params['aitmc']; |
|
| 253 | 253 | |
| 254 | - $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | - $grd->cssStyle = $params['tbls']; |
|
| 256 | - $grd->itemStyle = $params['itms']; |
|
| 257 | - $grd->altItemStyle = $params['aitms']; |
|
| 254 | + $grd->columnHeaderStyle = $params['chdrs']; |
|
| 255 | + $grd->cssStyle = $params['tbls']; |
|
| 256 | + $grd->itemStyle = $params['itms']; |
|
| 257 | + $grd->altItemStyle = $params['aitms']; |
|
| 258 | 258 | |
| 259 | - $grd->columns = $params['cols']; |
|
| 260 | - $grd->fields = $params['flds']; |
|
| 261 | - $grd->colWidths = $params['cwidth']; |
|
| 262 | - $grd->colAligns = $params['calign']; |
|
| 263 | - $grd->colColors = $params['ccolor']; |
|
| 264 | - $grd->colTypes = $params['ctype']; |
|
| 259 | + $grd->columns = $params['cols']; |
|
| 260 | + $grd->fields = $params['flds']; |
|
| 261 | + $grd->colWidths = $params['cwidth']; |
|
| 262 | + $grd->colAligns = $params['calign']; |
|
| 263 | + $grd->colColors = $params['ccolor']; |
|
| 264 | + $grd->colTypes = $params['ctype']; |
|
| 265 | 265 | |
| 266 | - $grd->cellPadding = $params['cpad']; |
|
| 267 | - $grd->cellSpacing = $params['cspace']; |
|
| 268 | - $grd->header = $params['head']; |
|
| 269 | - $grd->footer = $params['foot']; |
|
| 270 | - $grd->pageSize = $params['psize']; |
|
| 271 | - $grd->pagerLocation = $params['ploc']; |
|
| 272 | - $grd->pagerClass = $params['pclass']; |
|
| 273 | - $grd->pagerStyle = $params['pstyle']; |
|
| 274 | - $o = $grd->render(); |
|
| 275 | - break; |
|
| 266 | + $grd->cellPadding = $params['cpad']; |
|
| 267 | + $grd->cellSpacing = $params['cspace']; |
|
| 268 | + $grd->header = $params['head']; |
|
| 269 | + $grd->footer = $params['foot']; |
|
| 270 | + $grd->pageSize = $params['psize']; |
|
| 271 | + $grd->pagerLocation = $params['ploc']; |
|
| 272 | + $grd->pagerClass = $params['pclass']; |
|
| 273 | + $grd->pagerStyle = $params['pstyle']; |
|
| 274 | + $o = $grd->render(); |
|
| 275 | + break; |
|
| 276 | 276 | |
| 277 | - case 'htmlentities': |
|
| 278 | - $value = parseInput($value); |
|
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | - // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | - $value = str_replace('||', '', $value); |
|
| 282 | - } |
|
| 283 | - $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | - break; |
|
| 277 | + case 'htmlentities': |
|
| 278 | + $value = parseInput($value); |
|
| 279 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | + // remove delimiter from checkbox and listbox-multiple TVs |
|
| 281 | + $value = str_replace('||', '', $value); |
|
| 282 | + } |
|
| 283 | + $o = htmlentities($value, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
| 284 | + break; |
|
| 285 | 285 | |
| 286 | - case 'custom_widget': |
|
| 287 | - $widget_output = ''; |
|
| 288 | - $o = ''; |
|
| 289 | - /* If we are loading a file */ |
|
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 294 | - } else { |
|
| 295 | - $widget_output = file_get_contents($file_name); |
|
| 296 | - } |
|
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 301 | - } else { |
|
| 302 | - /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | - include $file_name; |
|
| 304 | - } |
|
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | - $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | - $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | - $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | - $widget_output = eval($eval_str); |
|
| 311 | - } elseif($value !== '') { |
|
| 312 | - $widget_output = $params['output']; |
|
| 313 | - } else { |
|
| 314 | - $widget_output = ''; |
|
| 315 | - } |
|
| 316 | - if(is_string($widget_output)) { |
|
| 317 | - $_ = $modx->config['enable_filter']; |
|
| 318 | - $modx->config['enable_filter'] = 1; |
|
| 319 | - $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | - $modx->config['enable_filter'] = $_; |
|
| 321 | - $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | - } else { |
|
| 323 | - $o = $widget_output; |
|
| 324 | - } |
|
| 325 | - break; |
|
| 286 | + case 'custom_widget': |
|
| 287 | + $widget_output = ''; |
|
| 288 | + $o = ''; |
|
| 289 | + /* If we are loading a file */ |
|
| 290 | + if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | + if(!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name . ' does not exist'; |
|
| 294 | + } else { |
|
| 295 | + $widget_output = file_get_contents($file_name); |
|
| 296 | + } |
|
| 297 | + } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | + if(!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name . ' does not exist'; |
|
| 301 | + } else { |
|
| 302 | + /* The included file needs to set $widget_output. Can be string, array, object */ |
|
| 303 | + include $file_name; |
|
| 304 | + } |
|
| 305 | + } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | + $chunk_name = trim(substr($params['output'], 7)); |
|
| 307 | + $widget_output = $modx->getChunk($chunk_name); |
|
| 308 | + } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | + $eval_str = trim(substr($params['output'], 6)); |
|
| 310 | + $widget_output = eval($eval_str); |
|
| 311 | + } elseif($value !== '') { |
|
| 312 | + $widget_output = $params['output']; |
|
| 313 | + } else { |
|
| 314 | + $widget_output = ''; |
|
| 315 | + } |
|
| 316 | + if(is_string($widget_output)) { |
|
| 317 | + $_ = $modx->config['enable_filter']; |
|
| 318 | + $modx->config['enable_filter'] = 1; |
|
| 319 | + $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
|
| 320 | + $modx->config['enable_filter'] = $_; |
|
| 321 | + $o = $modx->parseDocumentSource($widget_output); |
|
| 322 | + } else { |
|
| 323 | + $o = $widget_output; |
|
| 324 | + } |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | - default: |
|
| 328 | - $value = parseInput($value); |
|
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | - // add separator |
|
| 331 | - $value = explode('||', $value); |
|
| 332 | - $value = implode($sep, $value); |
|
| 333 | - } |
|
| 334 | - $o = $value; |
|
| 335 | - break; |
|
| 336 | - } |
|
| 337 | - return $o; |
|
| 327 | + default: |
|
| 328 | + $value = parseInput($value); |
|
| 329 | + if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | + // add separator |
|
| 331 | + $value = explode('||', $value); |
|
| 332 | + $value = implode($sep, $value); |
|
| 333 | + } |
|
| 334 | + $o = $value; |
|
| 335 | + break; |
|
| 336 | + } |
|
| 337 | + return $o; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | 344 | function decodeParamValue($s) { |
| 345 | - $s = str_replace("%3D", '=', $s); // = |
|
| 346 | - return str_replace("%26", '&', $s); // & |
|
| 345 | + $s = str_replace("%3D", '=', $s); // = |
|
| 346 | + return str_replace("%26", '&', $s); // & |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -357,19 +357,19 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
| 359 | 359 | $modx = evolutionCMS(); |
| 360 | - if($modx->db->isResult($src)) { |
|
| 361 | - // must be a recordset |
|
| 362 | - $rows = array(); |
|
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | - return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | - } else { |
|
| 366 | - // must be a text |
|
| 367 | - if($type == "array") { |
|
| 368 | - return explode($delim, $src); |
|
| 369 | - } else { |
|
| 370 | - return $src; |
|
| 371 | - } |
|
| 372 | - } |
|
| 360 | + if($modx->db->isResult($src)) { |
|
| 361 | + // must be a recordset |
|
| 362 | + $rows = array(); |
|
| 363 | + while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | + return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | + } else { |
|
| 366 | + // must be a text |
|
| 367 | + if($type == "array") { |
|
| 368 | + return explode($delim, $src); |
|
| 369 | + } else { |
|
| 370 | + return $src; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -377,21 +377,21 @@ discard block |
||
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | 379 | function getUnixtimeFromDateString($value) { |
| 380 | - $timestamp = false; |
|
| 381 | - // Check for MySQL or legacy style date |
|
| 382 | - $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | - $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | - $matches = array(); |
|
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - // If those didn't work, use strtotime to figure out the date |
|
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 394 | - $timestamp = strtotime($value); |
|
| 395 | - } |
|
| 396 | - return $timestamp; |
|
| 380 | + $timestamp = false; |
|
| 381 | + // Check for MySQL or legacy style date |
|
| 382 | + $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | + $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | + $matches = array(); |
|
| 385 | + if(strpos($value, '-') !== false) { |
|
| 386 | + if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | + } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + // If those didn't work, use strtotime to figure out the date |
|
| 393 | + if($timestamp === false || $timestamp === -1) { |
|
| 394 | + $timestamp = strtotime($value); |
|
| 395 | + } |
|
| 396 | + return $timestamp; |
|
| 397 | 397 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class DATEPICKER {
|
| 4 | - function __construct() {
|
|
| 5 | - } |
|
| 4 | + function __construct() {
|
|
| 5 | + } |
|
| 6 | 6 | |
| 7 | - function getDP() {
|
|
| 8 | - $modx = evolutionCMS(); global $_lang; |
|
| 7 | + function getDP() {
|
|
| 8 | + $modx = evolutionCMS(); global $_lang; |
|
| 9 | 9 | |
| 10 | - $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | - return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | - } |
|
| 10 | + $tpl = file_get_contents(dirname(__FILE__) . '/datepicker.tpl'); |
|
| 11 | + return $modx->parseText($tpl, $_lang, '[%', '%]'); |
|
| 12 | + } |
|
| 13 | 13 | } |