@@ -8,8 +8,8 @@ |
||
| 8 | 8 | ******************************************************* |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -use PHPMailer\PHPMailer\PHPMailer; |
|
| 12 | 11 | use PHPMailer\PHPMailer\Exception as PHPMailerException; |
| 12 | +use PHPMailer\PHPMailer\PHPMailer; |
|
| 13 | 13 | |
| 14 | 14 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/Exception.php'; |
| 15 | 15 | require MODX_MANAGER_PATH . 'includes/controls/phpmailer/PHPMailer.php'; |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | -if (!$modx->hasPermission('logs')) {
|
|
| 5 | +if (!$modx->hasPermission('logs')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -function array_unique_multi($array, $checkKey) |
|
| 10 | -{
|
|
| 9 | +function array_unique_multi($array, $checkKey) |
|
| 10 | +{ |
|
| 11 | 11 | // Use the builtin if we're not a multi-dimensional array |
| 12 | - if (!is_array(current($array)) || empty($checkKey)) {
|
|
| 12 | + if (!is_array(current($array)) || empty($checkKey)) { |
|
| 13 | 13 | return array_unique($array); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | $ret = array(); |
| 17 | 17 | $checkValues = array(); // contains the unique key Values |
| 18 | - foreach ($array as $key => $current) {
|
|
| 19 | - if (in_array($current[$checkKey], $checkValues)) {
|
|
| 18 | + foreach ($array as $key => $current) { |
|
| 19 | + if (in_array($current[$checkKey], $checkValues)) { |
|
| 20 | 20 | continue; |
| 21 | 21 | } // duplicate |
| 22 | 22 | |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | return $ret; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -function record_sort($array, $key) |
|
| 30 | -{
|
|
| 29 | +function record_sort($array, $key) |
|
| 30 | +{ |
|
| 31 | 31 | $hash = array(); |
| 32 | - foreach ($array as $k => $v) {
|
|
| 32 | + foreach ($array as $k => $v) { |
|
| 33 | 33 | $hash[$k] = $v[$key]; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | natsort($hash); |
| 37 | 37 | |
| 38 | 38 | $records = array(); |
| 39 | - foreach ($hash as $k => $row) {
|
|
| 39 | + foreach ($hash as $k => $row) { |
|
| 40 | 40 | $records[$k] = $array[$k]; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | <?php |
| 64 | 64 | // get all users currently in the log |
| 65 | 65 | $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username'); |
| 66 | - foreach ($logs_user as $row) {
|
|
| 66 | + foreach ($logs_user as $row) { |
|
| 67 | 67 | $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : ''; |
| 68 | 68 | echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n"; |
| 69 | 69 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | // get all available actions in the log |
| 81 | 81 | include_once "actionlist.inc.php"; |
| 82 | 82 | $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action'); |
| 83 | - foreach ($logs_actions as $row) {
|
|
| 83 | + foreach ($logs_actions as $row) { |
|
| 84 | 84 | $action = getAction($row['action']); |
| 85 | - if ($action == 'Idle') {
|
|
| 85 | + if ($action == 'Idle') { |
|
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | 88 | $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | <?php |
| 101 | 101 | // get all itemid currently in logging |
| 102 | 102 | $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid'); |
| 103 | - foreach ($logs_items as $row) {
|
|
| 103 | + foreach ($logs_items as $row) { |
|
| 104 | 104 | $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : ''; |
| 105 | 105 | echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n"; |
| 106 | 106 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | <?php |
| 117 | 117 | // get all itemname currently in logging |
| 118 | 118 | $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname'); |
| 119 | - foreach ($logs_names as $row) {
|
|
| 119 | + foreach ($logs_names as $row) { |
|
| 120 | 120 | $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : ''; |
| 121 | 121 | echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n"; |
| 122 | 122 | } |
@@ -172,36 +172,36 @@ discard block |
||
| 172 | 172 | <div class="container container-body"> |
| 173 | 173 | |
| 174 | 174 | <?php |
| 175 | -if (isset($_REQUEST['log_submit'])) {
|
|
| 175 | +if (isset($_REQUEST['log_submit'])) { |
|
| 176 | 176 | // get the selections the user made. |
| 177 | 177 | $sqladd = array(); |
| 178 | - if ($_REQUEST['searchuser'] != 0) {
|
|
| 178 | + if ($_REQUEST['searchuser'] != 0) { |
|
| 179 | 179 | $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'"; |
| 180 | 180 | } |
| 181 | - if ($_REQUEST['action'] != 0) {
|
|
| 181 | + if ($_REQUEST['action'] != 0) { |
|
| 182 | 182 | $sqladd[] = "action=" . (int)$_REQUEST['action']; |
| 183 | 183 | } |
| 184 | - if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
|
|
| 184 | + if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") { |
|
| 185 | 185 | $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'"; |
| 186 | 186 | } |
| 187 | - if ($_REQUEST['itemname'] != '0') {
|
|
| 187 | + if ($_REQUEST['itemname'] != '0') { |
|
| 188 | 188 | $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'"; |
| 189 | 189 | } |
| 190 | - if ($_REQUEST['message'] != "") {
|
|
| 190 | + if ($_REQUEST['message'] != "") { |
|
| 191 | 191 | $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; |
| 192 | 192 | } |
| 193 | 193 | // date stuff |
| 194 | - if ($_REQUEST['datefrom'] != "") {
|
|
| 194 | + if ($_REQUEST['datefrom'] != "") { |
|
| 195 | 195 | $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); |
| 196 | 196 | } |
| 197 | - if ($_REQUEST['dateto'] != "") {
|
|
| 197 | + if ($_REQUEST['dateto'] != "") { |
|
| 198 | 198 | $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // If current position is not set, set it to zero |
| 202 | - if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
|
|
| 202 | + if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { |
|
| 203 | 203 | $int_cur_position = 0; |
| 204 | - } else {
|
|
| 204 | + } else { |
|
| 205 | 205 | $int_cur_position = $_REQUEST['int_cur_position']; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
|
| 217 | 217 | |
| 218 | -if ($limit < 1) {
|
|
| 218 | +if ($limit < 1) { |
|
| 219 | 219 | echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>'; |
| 220 | -} else {
|
|
| 220 | +} else { |
|
| 221 | 221 | echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>'; |
| 222 | 222 | |
| 223 | 223 | include_once "paginate.inc.php"; |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " "); |
| 237 | 237 | $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " "); |
| 238 | 238 | $pagesfound = sizeof($array_row_paging); |
| 239 | - if ($pagesfound > 6) {
|
|
| 239 | + if ($pagesfound > 6) { |
|
| 240 | 240 | $paging .= $array_row_paging[$current_row - 2]; // ." "; |
| 241 | 241 | $paging .= $array_row_paging[$current_row - 1]; // ." "; |
| 242 | 242 | $paging .= $array_row_paging[$current_row]; // ." "; |
| 243 | 243 | $paging .= $array_row_paging[$current_row + 1]; // ." "; |
| 244 | 244 | $paging .= $array_row_paging[$current_row + 2]; // ." "; |
| 245 | - } else {
|
|
| 246 | - for ($i = 0; $i < $pagesfound; $i++) {
|
|
| 245 | + } else { |
|
| 246 | + for ($i = 0; $i < $pagesfound; $i++) { |
|
| 247 | 247 | $paging .= $array_row_paging[$i] . " "; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | // grab the entire log file... |
| 279 | 279 | $logentries = array(); |
| 280 | 280 | $i = 0; |
| 281 | - while ($logentry = $modx->db->getRow($rs)) {
|
|
| 282 | - if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
|
|
| 281 | + while ($logentry = $modx->db->getRow($rs)) { |
|
| 282 | + if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) { |
|
| 283 | 283 | $item = '<div style="text-align:center;">-</div>'; |
| 284 | - } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
|
|
| 284 | + } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { |
|
| 285 | 285 | $item = '<a href="index.php?a=3&id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>'; |
| 286 | - } else {
|
|
| 286 | + } else { |
|
| 287 | 287 | $item = $logentry['itemname']; |
| 288 | 288 | } |
| 289 | 289 | //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' |
@@ -318,6 +318,6 @@ discard block |
||
| 318 | 318 | // @see index.php @ 915 |
| 319 | 319 | global $action; |
| 320 | 320 | $action = 1; |
| 321 | -} else {
|
|
| 321 | +} else { |
|
| 322 | 322 | echo $_lang["mgrlog_noquery"]; |
| 323 | 323 | } |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | $this->db = & $modx->db; |
| 19 | 19 | $this->db_tbl['categories'] = $modx->getFullTableName('categories'); |
| 20 | 20 | |
| 21 | - foreach( $this->elements as $element ) |
|
| 22 | - { |
|
| 21 | + foreach( $this->elements as $element ) { |
|
| 23 | 22 | $this->db_tbl[$element] = $modx->getFullTableName('site_' . $element ); |
| 24 | 23 | } |
| 25 | 24 | } |
@@ -69,8 +68,7 @@ discard block |
||
| 69 | 68 | |
| 70 | 69 | public function getAssignedElements( $category_id, $element ) |
| 71 | 70 | { |
| 72 | - if( in_array( $element, $this->elements, true ) ) |
|
| 73 | - { |
|
| 71 | + if( in_array( $element, $this->elements, true ) ) { |
|
| 74 | 72 | $elements = $this->db->makeArray( |
| 75 | 73 | $this->db->select( |
| 76 | 74 | '*', |
@@ -80,11 +78,9 @@ discard block |
||
| 80 | 78 | ); |
| 81 | 79 | |
| 82 | 80 | // correct the name of templates |
| 83 | - if( $element === 'templates' ) |
|
| 84 | - { |
|
| 81 | + if( $element === 'templates' ) { |
|
| 85 | 82 | $_elements_count = count($elements); |
| 86 | - for( $i=0; $i < $_elements_count; $i++ ) |
|
| 87 | - { |
|
| 83 | + for( $i=0; $i < $_elements_count; $i++ ) { |
|
| 88 | 84 | $elements[$i]['name'] = $elements[$i]['templatename']; |
| 89 | 85 | } |
| 90 | 86 | } |
@@ -96,8 +92,7 @@ discard block |
||
| 96 | 92 | public function getAllAssignedElements( $category_id ) |
| 97 | 93 | { |
| 98 | 94 | $elements = array(); |
| 99 | - foreach( $this->elements as $element ) |
|
| 100 | - { |
|
| 95 | + foreach( $this->elements as $element ) { |
|
| 101 | 96 | $elements[$element] = $this->getAssignedElements( $category_id, $element ); |
| 102 | 97 | } |
| 103 | 98 | return $elements; |
@@ -106,8 +101,7 @@ discard block |
||
| 106 | 101 | public function deleteCategory( $category_id ) |
| 107 | 102 | { |
| 108 | 103 | $_update = array('category' => 0); |
| 109 | - foreach( $this->elements as $element ) |
|
| 110 | - { |
|
| 104 | + foreach( $this->elements as $element ) { |
|
| 111 | 105 | $this->db->update( |
| 112 | 106 | $_update, |
| 113 | 107 | $this->db_tbl[$element], |
@@ -126,8 +120,7 @@ discard block |
||
| 126 | 120 | public function updateCategory( $category_id, $data = array() ) |
| 127 | 121 | { |
| 128 | 122 | if( empty( $data ) |
| 129 | - || empty( $category_id ) ) |
|
| 130 | - { |
|
| 123 | + || empty( $category_id ) ) { |
|
| 131 | 124 | return false; |
| 132 | 125 | } |
| 133 | 126 | |
@@ -142,8 +135,7 @@ discard block |
||
| 142 | 135 | "`id` = '" . (int)$category_id . "'" |
| 143 | 136 | ); |
| 144 | 137 | |
| 145 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 146 | - { |
|
| 138 | + if( $this->db->getAffectedRows() === 1 ) { |
|
| 147 | 139 | return true; |
| 148 | 140 | } |
| 149 | 141 | |
@@ -152,8 +144,7 @@ discard block |
||
| 152 | 144 | |
| 153 | 145 | public function addCategory( $category_name, $category_rank ) |
| 154 | 146 | { |
| 155 | - if( $this->isCategoryExists( $category_name ) ) |
|
| 156 | - { |
|
| 147 | + if( $this->isCategoryExists( $category_name ) ) { |
|
| 157 | 148 | return false; |
| 158 | 149 | } |
| 159 | 150 | |
@@ -167,8 +158,7 @@ discard block |
||
| 167 | 158 | $this->db_tbl['categories'] |
| 168 | 159 | ); |
| 169 | 160 | |
| 170 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 171 | - { |
|
| 161 | + if( $this->db->getAffectedRows() === 1 ) { |
|
| 172 | 162 | return $this->db->getInsertId(); |
| 173 | 163 | } |
| 174 | 164 | |
@@ -187,8 +177,7 @@ discard block |
||
| 187 | 177 | ) |
| 188 | 178 | ); |
| 189 | 179 | |
| 190 | - if( $this->db->getAffectedRows() === 1 ) |
|
| 191 | - { |
|
| 180 | + if( $this->db->getAffectedRows() === 1 ) { |
|
| 192 | 181 | return $category_id; |
| 193 | 182 | } |
| 194 | 183 | return false; |
@@ -304,7 +304,8 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | public function save($fields, $table, $where = '') |
| 307 | - { // This is similar to "replace into table". |
|
| 307 | + { |
|
| 308 | +// This is similar to "replace into table". |
|
| 308 | 309 | |
| 309 | 310 | if ($where === '') { |
| 310 | 311 | $mode = 'insert'; |
@@ -386,7 +387,7 @@ discard block |
||
| 386 | 387 | { |
| 387 | 388 | $out = false; |
| 388 | 389 | if (is_object($ds)) { |
| 389 | - switch($mode){ |
|
| 390 | + switch($mode) { |
|
| 390 | 391 | case 'assoc': |
| 391 | 392 | $out = $ds->fetch_assoc(); |
| 392 | 393 | break; |
@@ -8,7 +8,8 @@ discard block |
||
| 8 | 8 | * |
| 9 | 9 | * @author Jason Coward <[email protected]> (MODX) |
| 10 | 10 | */ |
| 11 | -class MakeTable { |
|
| 11 | +class MakeTable |
|
| 12 | +{ |
|
| 12 | 13 | public $actionField; |
| 13 | 14 | public $cellAction; |
| 14 | 15 | public $linkAction; |
@@ -33,7 +34,8 @@ discard block |
||
| 33 | 34 | public $fieldHeaders; |
| 34 | 35 | public $extra; |
| 35 | 36 | |
| 36 | - public function __construct() { |
|
| 37 | + public function __construct() |
|
| 38 | + { |
|
| 37 | 39 | $this->fieldHeaders= array(); |
| 38 | 40 | $this->excludeFields= array(); |
| 39 | 41 | $this->actionField= ''; |
@@ -60,7 +62,8 @@ discard block |
||
| 60 | 62 | * |
| 61 | 63 | * @param $value A URL to execute when table cells are clicked. |
| 62 | 64 | */ |
| 63 | - public function setCellAction($value) { |
|
| 65 | + public function setCellAction($value) |
|
| 66 | + { |
|
| 64 | 67 | $this->cellAction= $this->prepareLink($value); |
| 65 | 68 | } |
| 66 | 69 | |
@@ -69,7 +72,8 @@ discard block |
||
| 69 | 72 | * |
| 70 | 73 | * @param $value A URL to execute when text within table cells are clicked. |
| 71 | 74 | */ |
| 72 | - public function setLinkAction($value) { |
|
| 75 | + public function setLinkAction($value) |
|
| 76 | + { |
|
| 73 | 77 | $this->linkAction= $this->prepareLink($value); |
| 74 | 78 | } |
| 75 | 79 | |
@@ -78,7 +82,8 @@ discard block |
||
| 78 | 82 | * |
| 79 | 83 | * @param $value A valid width attribute for the HTML TABLE tag |
| 80 | 84 | */ |
| 81 | - public function setTableWidth($value) { |
|
| 85 | + public function setTableWidth($value) |
|
| 86 | + { |
|
| 82 | 87 | $this->tableWidth= $value; |
| 83 | 88 | } |
| 84 | 89 | |
@@ -87,7 +92,8 @@ discard block |
||
| 87 | 92 | * |
| 88 | 93 | * @param $value A class for the main HTML TABLE. |
| 89 | 94 | */ |
| 90 | - public function setTableClass($value) { |
|
| 95 | + public function setTableClass($value) |
|
| 96 | + { |
|
| 91 | 97 | $this->tableClass= $value; |
| 92 | 98 | } |
| 93 | 99 | |
@@ -96,7 +102,8 @@ discard block |
||
| 96 | 102 | * |
| 97 | 103 | * @param $value A class for the main HTML TABLE. |
| 98 | 104 | */ |
| 99 | - public function setTableID($value) { |
|
| 105 | + public function setTableID($value) |
|
| 106 | + { |
|
| 100 | 107 | $this->tableID= $value; |
| 101 | 108 | } |
| 102 | 109 | |
@@ -105,7 +112,8 @@ discard block |
||
| 105 | 112 | * |
| 106 | 113 | * @param $value A class for the table header row. |
| 107 | 114 | */ |
| 108 | - public function setRowHeaderClass($value) { |
|
| 115 | + public function setRowHeaderClass($value) |
|
| 116 | + { |
|
| 109 | 117 | $this->rowHeaderClass= $value; |
| 110 | 118 | } |
| 111 | 119 | |
@@ -114,7 +122,8 @@ discard block |
||
| 114 | 122 | * |
| 115 | 123 | * @param $value A class for the table header row. |
| 116 | 124 | */ |
| 117 | - public function setThHeaderClass($value) { |
|
| 125 | + public function setThHeaderClass($value) |
|
| 126 | + { |
|
| 118 | 127 | $this->thClass= $value; |
| 119 | 128 | } |
| 120 | 129 | |
@@ -123,7 +132,8 @@ discard block |
||
| 123 | 132 | * |
| 124 | 133 | * @param $value A class for the column header row. |
| 125 | 134 | */ |
| 126 | - public function setColumnHeaderClass($value) { |
|
| 135 | + public function setColumnHeaderClass($value) |
|
| 136 | + { |
|
| 127 | 137 | $this->columnHeaderClass= $value; |
| 128 | 138 | } |
| 129 | 139 | |
@@ -132,7 +142,8 @@ discard block |
||
| 132 | 142 | * |
| 133 | 143 | * @param $value A class for regular table rows. |
| 134 | 144 | */ |
| 135 | - public function setRowRegularClass($value) { |
|
| 145 | + public function setRowRegularClass($value) |
|
| 146 | + { |
|
| 136 | 147 | $this->rowRegularClass= $value; |
| 137 | 148 | } |
| 138 | 149 | |
@@ -141,7 +152,8 @@ discard block |
||
| 141 | 152 | * |
| 142 | 153 | * @param $value A class for alternate table rows. |
| 143 | 154 | */ |
| 144 | - public function setRowAlternateClass($value) { |
|
| 155 | + public function setRowAlternateClass($value) |
|
| 156 | + { |
|
| 145 | 157 | $this->rowAlternateClass= $value; |
| 146 | 158 | } |
| 147 | 159 | |
@@ -150,7 +162,8 @@ discard block |
||
| 150 | 162 | * |
| 151 | 163 | * @param $value Indicates the INPUT form element type attribute. |
| 152 | 164 | */ |
| 153 | - public function setFormElementType($value) { |
|
| 165 | + public function setFormElementType($value) |
|
| 166 | + { |
|
| 154 | 167 | $this->formElementType= $value; |
| 155 | 168 | } |
| 156 | 169 | |
@@ -159,7 +172,8 @@ discard block |
||
| 159 | 172 | * |
| 160 | 173 | * @param $value Indicates the INPUT form element name attribute. |
| 161 | 174 | */ |
| 162 | - public function setFormElementName($value) { |
|
| 175 | + public function setFormElementName($value) |
|
| 176 | + { |
|
| 163 | 177 | $this->formElementName= $value; |
| 164 | 178 | } |
| 165 | 179 | |
@@ -169,7 +183,8 @@ discard block |
||
| 169 | 183 | * |
| 170 | 184 | * @param $value Indicates the FORM name attribute. |
| 171 | 185 | */ |
| 172 | - public function setFormName($value) { |
|
| 186 | + public function setFormName($value) |
|
| 187 | + { |
|
| 173 | 188 | $this->formName= $value; |
| 174 | 189 | } |
| 175 | 190 | |
@@ -178,7 +193,8 @@ discard block |
||
| 178 | 193 | * |
| 179 | 194 | * @param $value Indicates the FORM action attribute. |
| 180 | 195 | */ |
| 181 | - public function setFormAction($value) { |
|
| 196 | + public function setFormAction($value) |
|
| 197 | + { |
|
| 182 | 198 | $this->formAction= $value; |
| 183 | 199 | } |
| 184 | 200 | |
@@ -187,7 +203,8 @@ discard block |
||
| 187 | 203 | * |
| 188 | 204 | * @param $value An Array of field keys to exclude from the table. |
| 189 | 205 | */ |
| 190 | - public function setExcludeFields($value) { |
|
| 206 | + public function setExcludeFields($value) |
|
| 207 | + { |
|
| 191 | 208 | $this->excludeFields= $value; |
| 192 | 209 | } |
| 193 | 210 | |
@@ -196,7 +213,8 @@ discard block |
||
| 196 | 213 | * |
| 197 | 214 | * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme. |
| 198 | 215 | */ |
| 199 | - public function setRowAlternatingScheme($value) { |
|
| 216 | + public function setRowAlternatingScheme($value) |
|
| 217 | + { |
|
| 200 | 218 | $this->rowAlternatingScheme= $value; |
| 201 | 219 | } |
| 202 | 220 | |
@@ -206,7 +224,8 @@ discard block |
||
| 206 | 224 | * |
| 207 | 225 | * @param $value The key of the field to add as a query string parameter. |
| 208 | 226 | */ |
| 209 | - public function setActionFieldName($value) { |
|
| 227 | + public function setActionFieldName($value) |
|
| 228 | + { |
|
| 210 | 229 | $this->actionField= $value; |
| 211 | 230 | } |
| 212 | 231 | |
@@ -216,7 +235,8 @@ discard block |
||
| 216 | 235 | * @param $value An Array of column widths in the order of the keys in the |
| 217 | 236 | * source table array. |
| 218 | 237 | */ |
| 219 | - public function setColumnWidths($widthArray) { |
|
| 238 | + public function setColumnWidths($widthArray) |
|
| 239 | + { |
|
| 220 | 240 | $this->columnWidths= $widthArray; |
| 221 | 241 | } |
| 222 | 242 | |
@@ -225,7 +245,8 @@ discard block |
||
| 225 | 245 | * |
| 226 | 246 | * @param $value Indicates the INPUT form element type attribute. |
| 227 | 247 | */ |
| 228 | - public function setSelectedValues($valueArray) { |
|
| 248 | + public function setSelectedValues($valueArray) |
|
| 249 | + { |
|
| 229 | 250 | $this->selectedValues= $valueArray; |
| 230 | 251 | } |
| 231 | 252 | |
@@ -235,7 +256,8 @@ discard block |
||
| 235 | 256 | * |
| 236 | 257 | * @param $value A string of additional content. |
| 237 | 258 | */ |
| 238 | - public function setExtra($value) { |
|
| 259 | + public function setExtra($value) |
|
| 260 | + { |
|
| 239 | 261 | $this->extra= $value; |
| 240 | 262 | } |
| 241 | 263 | |
@@ -244,7 +266,8 @@ discard block |
||
| 244 | 266 | * |
| 245 | 267 | * @param $columnPosition The index of the column to get the width for. |
| 246 | 268 | */ |
| 247 | - public function getColumnWidth($columnPosition) { |
|
| 269 | + public function getColumnWidth($columnPosition) |
|
| 270 | + { |
|
| 248 | 271 | $currentWidth= ''; |
| 249 | 272 | if (is_array($this->columnWidths)) { |
| 250 | 273 | $currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
@@ -257,7 +280,8 @@ discard block |
||
| 257 | 280 | * |
| 258 | 281 | * @param $value The position of the current row being rendered. |
| 259 | 282 | */ |
| 260 | - public function determineRowClass($position) { |
|
| 283 | + public function determineRowClass($position) |
|
| 284 | + { |
|
| 261 | 285 | switch ($this->rowAlternatingScheme) { |
| 262 | 286 | case 'ODD' : |
| 263 | 287 | $modRemainder= 1; |
@@ -280,7 +304,8 @@ discard block |
||
| 280 | 304 | * |
| 281 | 305 | * @param $value Indicates the INPUT form element type attribute. |
| 282 | 306 | */ |
| 283 | - public function getCellAction($currentActionFieldValue) { |
|
| 307 | + public function getCellAction($currentActionFieldValue) |
|
| 308 | + { |
|
| 284 | 309 | if ($this->cellAction) { |
| 285 | 310 | $cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
| 286 | 311 | } |
@@ -293,7 +318,8 @@ discard block |
||
| 293 | 318 | * @param $currentActionFieldValue The value to be applied to the link action. |
| 294 | 319 | * @param $value The value of the cell. |
| 295 | 320 | */ |
| 296 | - public function createCellText($currentActionFieldValue, $value) { |
|
| 321 | + public function createCellText($currentActionFieldValue, $value) |
|
| 322 | + { |
|
| 297 | 323 | $cell .= $value; |
| 298 | 324 | if ($this->linkAction) { |
| 299 | 325 | $cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
@@ -305,7 +331,8 @@ discard block |
||
| 305 | 331 | * Sets an option to generate a check all link when checkbox is indicated |
| 306 | 332 | * as the table formElementType. |
| 307 | 333 | */ |
| 308 | - public function setAllOption() { |
|
| 334 | + public function setAllOption() |
|
| 335 | + { |
|
| 309 | 336 | $this->allOption= 1; |
| 310 | 337 | } |
| 311 | 338 | |
@@ -314,7 +341,8 @@ discard block |
||
| 314 | 341 | * |
| 315 | 342 | * @param $value Indicates the INPUT form element type attribute. |
| 316 | 343 | */ |
| 317 | - public function prepareLink($link) { |
|
| 344 | + public function prepareLink($link) |
|
| 345 | + { |
|
| 318 | 346 | if (strstr($link, '?')) { |
| 319 | 347 | $end= '&'; |
| 320 | 348 | } else { |
@@ -333,7 +361,8 @@ discard block |
||
| 333 | 361 | * the $fieldsArray where the values represent the alt heading content |
| 334 | 362 | * for each column. |
| 335 | 363 | */ |
| 336 | - public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") { |
|
| 364 | + public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") |
|
| 365 | + { |
|
| 337 | 366 | global $_lang; |
| 338 | 367 | if (is_array($fieldsArray)) { |
| 339 | 368 | $i= 0; |
@@ -369,7 +398,8 @@ discard block |
||
| 369 | 398 | if ($this->formElementType) { |
| 370 | 399 | $table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
| 371 | 400 | } |
| 372 | - if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
|
| 401 | + if (strlen($this->pageNav) > 1) { |
|
| 402 | +//changed to display the pagination if exists. |
|
| 373 | 403 | /* commented this part because of cookie |
| 374 | 404 | $table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">'; |
| 375 | 405 | $pageSizes= array (10, 25, 50, 100, 250); |
@@ -416,7 +446,8 @@ discard block |
||
| 416 | 446 | * @param $numRecords The number of records to show per page. |
| 417 | 447 | * @param $qs An optional query string to be appended to the paging links |
| 418 | 448 | */ |
| 419 | - public function createPagingNavigation($numRecords, $qs='') { |
|
| 449 | + public function createPagingNavigation($numRecords, $qs='') |
|
| 450 | + { |
|
| 420 | 451 | global $_lang; |
| 421 | 452 | $currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1); |
| 422 | 453 | $numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
@@ -431,10 +462,11 @@ discard block |
||
| 431 | 462 | $offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0); |
| 432 | 463 | $i= 1; |
| 433 | 464 | while ($i < 10 && ($currentPage + $offset <= $numPages)) { |
| 434 | - if ($currentPage == $currentPage + $offset) |
|
| 435 | - $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true); |
|
| 436 | - else |
|
| 437 | - $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset); |
|
| 465 | + if ($currentPage == $currentPage + $offset) { |
|
| 466 | + $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true); |
|
| 467 | + } else { |
|
| 468 | + $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset); |
|
| 469 | + } |
|
| 438 | 470 | $i ++; |
| 439 | 471 | $offset ++; |
| 440 | 472 | } |
@@ -457,11 +489,14 @@ discard block |
||
| 457 | 489 | * @param $currentPage Indicates if the link is to the current page. |
| 458 | 490 | * @param $qs And optional query string to be appended to the link. |
| 459 | 491 | */ |
| 460 | - public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') { |
|
| 492 | + public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') |
|
| 493 | + { |
|
| 461 | 494 | global $modx; |
| 462 | 495 | $orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: ''; |
| 463 | 496 | $orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: ''; |
| 464 | - if (!empty($qs)) $qs= "?$qs"; |
|
| 497 | + if (!empty($qs)) { |
|
| 498 | + $qs= "?$qs"; |
|
| 499 | + } |
|
| 465 | 500 | $link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum"; |
| 466 | 501 | $nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
| 467 | 502 | return $nav; |
@@ -474,7 +509,8 @@ discard block |
||
| 474 | 509 | * @param $isChecked Indicates if the checked attribute should apply to the |
| 475 | 510 | * element. |
| 476 | 511 | */ |
| 477 | - public function addFormField($value, $isChecked) { |
|
| 512 | + public function addFormField($value, $isChecked) |
|
| 513 | + { |
|
| 478 | 514 | if ($this->formElementType) { |
| 479 | 515 | $checked= $isChecked? "checked ": ""; |
| 480 | 516 | $field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
@@ -486,7 +522,8 @@ discard block |
||
| 486 | 522 | * Generates the proper LIMIT clause for queries to retrieve paged results in |
| 487 | 523 | * a MakeTable $fieldsArray. |
| 488 | 524 | */ |
| 489 | - public function handlePaging() { |
|
| 525 | + public function handlePaging() |
|
| 526 | + { |
|
| 490 | 527 | $offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
| 491 | 528 | $limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
| 492 | 529 | return $limitClause; |
@@ -498,7 +535,8 @@ discard block |
||
| 498 | 535 | * |
| 499 | 536 | * @param $natural_order If true, the results are returned in natural order. |
| 500 | 537 | */ |
| 501 | - public function handleSorting($natural_order=false) { |
|
| 538 | + public function handleSorting($natural_order=false) |
|
| 539 | + { |
|
| 502 | 540 | $orderByClause= ''; |
| 503 | 541 | if (!$natural_order) { |
| 504 | 542 | $orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id"; |
@@ -516,7 +554,8 @@ discard block |
||
| 516 | 554 | * @param $text The text for the link (e.g. table column header). |
| 517 | 555 | * @param $qs An optional query string to append to the order by link. |
| 518 | 556 | */ |
| 519 | - public function prepareOrderByLink($key, $text, $qs='') { |
|
| 557 | + public function prepareOrderByLink($key, $text, $qs='') |
|
| 558 | + { |
|
| 520 | 559 | global $modx; |
| 521 | 560 | if (!empty($_GET['orderdir'])) { |
| 522 | 561 | $orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc'; |
@@ -524,7 +563,9 @@ discard block |
||
| 524 | 563 | $orderDir= '&orderdir=asc'; |
| 525 | 564 | } |
| 526 | 565 | if (!empty($qs)) { |
| 527 | - if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&'; |
|
| 566 | + if (!strrpos($qs, '&')==strlen($qs)-1) { |
|
| 567 | + $qs.= '&'; |
|
| 568 | + } |
|
| 528 | 569 | } |
| 529 | 570 | return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
| 530 | 571 | } |
@@ -1,8 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $userid = (int)$value; |
| 3 | 3 | if (!isset($modx->filter->cache['ui'][$userid])) { |
| 4 | - if ($userid < 0) $user = $modx->getWebUserInfo(abs($userid)); |
|
| 5 | - else $user = $modx->getUserInfo($userid); |
|
| 4 | + if ($userid < 0) { |
|
| 5 | + $user = $modx->getWebUserInfo(abs($userid)); |
|
| 6 | + } else { |
|
| 7 | + $user = $modx->getUserInfo($userid); |
|
| 8 | + } |
|
| 6 | 9 | $modx->filter->cache['ui'][$userid] = $user; |
| 7 | 10 | } else { |
| 8 | 11 | $user = $modx->filter->cache['ui'][$userid]; |
@@ -1,9 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(strpos($opt,',')) list($limit,$delim) = explode(',', $opt); |
|
| 3 | -elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} |
|
| 4 | -else {$limit=124;$delim='';} |
|
| 2 | +if(strpos($opt,',')) { |
|
| 3 | + list($limit,$delim) = explode(',', $opt); |
|
| 4 | +} elseif(preg_match('/^[1-9][0-9]*$/',$opt)) {$limit=$opt;$delim='';} else {$limit=124;$delim='';} |
|
| 5 | 5 | |
| 6 | -if($delim==='') $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
| 6 | +if($delim==='') { |
|
| 7 | + $delim = $modx->config['manager_language']==='japanese-utf8' ? '。' : '.'; |
|
| 8 | +} |
|
| 7 | 9 | $limit = (int)$limit; |
| 8 | 10 | |
| 9 | 11 | $content = $modx->filter->parseDocumentSource($value); |
@@ -11,8 +13,9 @@ discard block |
||
| 11 | 13 | $content = strip_tags($content); |
| 12 | 14 | |
| 13 | 15 | $content = str_replace(array("\r\n","\r","\n","\t",' '),' ',$content); |
| 14 | -if(preg_match('/\s+/',$content)) |
|
| 16 | +if(preg_match('/\s+/',$content)) { |
|
| 15 | 17 | $content = preg_replace('/\s+/',' ',$content); |
| 18 | +} |
|
| 16 | 19 | $content = trim($content); |
| 17 | 20 | |
| 18 | 21 | $pos = $modx->filter->strpos($content, $delim); |
@@ -21,23 +24,35 @@ discard block |
||
| 21 | 24 | $_ = explode($delim, $content); |
| 22 | 25 | $text = ''; |
| 23 | 26 | foreach($_ as $v) { |
| 24 | - if($limit <= $modx->filter->strlen($text.$v.$delim)) break; |
|
| 27 | + if($limit <= $modx->filter->strlen($text.$v.$delim)) { |
|
| 28 | + break; |
|
| 29 | + } |
|
| 25 | 30 | $text .= $v.$delim; |
| 26 | 31 | } |
| 27 | - if($text) $content = $text; |
|
| 28 | -} |
|
| 32 | + if($text) { |
|
| 33 | + $content = $text; |
|
| 34 | + } |
|
| 35 | + } |
|
| 29 | 36 | |
| 30 | 37 | if($limit<$modx->filter->strlen($content) && strpos($content,' ')!==false) { |
| 31 | 38 | $_ = explode(' ', $content); |
| 32 | 39 | $text = ''; |
| 33 | 40 | foreach($_ as $v) { |
| 34 | - if($limit <= $modx->filter->strlen($text.$v.' ')) break; |
|
| 41 | + if($limit <= $modx->filter->strlen($text.$v.' ')) { |
|
| 42 | + break; |
|
| 43 | + } |
|
| 35 | 44 | $text .= $v . ' '; |
| 36 | 45 | } |
| 37 | - if($text!=='') $content = $text; |
|
| 38 | -} |
|
| 46 | + if($text!=='') { |
|
| 47 | + $content = $text; |
|
| 48 | + } |
|
| 49 | + } |
|
| 39 | 50 | |
| 40 | -if($limit < $modx->filter->strlen($content)) $content = $modx->filter->substr($content, 0, $limit); |
|
| 41 | -if($modx->filter->substr($content,-1)==$delim) $content = rtrim($content,$delim) . $delim; |
|
| 51 | +if($limit < $modx->filter->strlen($content)) { |
|
| 52 | + $content = $modx->filter->substr($content, 0, $limit); |
|
| 53 | +} |
|
| 54 | +if($modx->filter->substr($content,-1)==$delim) { |
|
| 55 | + $content = rtrim($content,$delim) . $delim; |
|
| 56 | +} |
|
| 42 | 57 | |
| 43 | 58 | return $content; |
@@ -1,16 +1,32 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | $this->old = new OldFunctions(); |
| 3 | -class OldFunctions { |
|
| 3 | +class OldFunctions |
|
| 4 | +{ |
|
| 4 | 5 | |
| 5 | - public function dbConnect() {global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
| 6 | - public function dbQuery($sql) {global $modx;return $modx->db->query($sql);} |
|
| 7 | - public function recordCount($rs) {global $modx;return $modx->db->getRecordCount($rs);} |
|
| 8 | - public function fetchRow($rs,$mode='assoc') {global $modx;return $modx->db->getRow($rs, $mode);} |
|
| 9 | - public function affectedRows($rs) {global $modx;return $modx->db->getAffectedRows($rs);} |
|
| 10 | - public function insertId($rs) {global $modx;return $modx->db->getInsertId($rs);} |
|
| 11 | - public function dbClose() {global $modx; $modx->db->disconnect();} |
|
| 6 | + public function dbConnect() |
|
| 7 | + { |
|
| 8 | +global $modx; $modx->db->connect();$modx->rs = $modx->db->conn;} |
|
| 9 | + public function dbQuery($sql) |
|
| 10 | + { |
|
| 11 | +global $modx;return $modx->db->query($sql);} |
|
| 12 | + public function recordCount($rs) |
|
| 13 | + { |
|
| 14 | +global $modx;return $modx->db->getRecordCount($rs);} |
|
| 15 | + public function fetchRow($rs,$mode='assoc') |
|
| 16 | + { |
|
| 17 | +global $modx;return $modx->db->getRow($rs, $mode);} |
|
| 18 | + public function affectedRows($rs) |
|
| 19 | + { |
|
| 20 | +global $modx;return $modx->db->getAffectedRows($rs);} |
|
| 21 | + public function insertId($rs) |
|
| 22 | + { |
|
| 23 | +global $modx;return $modx->db->getInsertId($rs);} |
|
| 24 | + public function dbClose() |
|
| 25 | + { |
|
| 26 | +global $modx; $modx->db->disconnect();} |
|
| 12 | 27 | |
| 13 | - public function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) { |
|
| 28 | + public function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) |
|
| 29 | + { |
|
| 14 | 30 | // first find out whether the value passed is an array |
| 15 | 31 | if (!is_array($array)) { |
| 16 | 32 | return "<ul><li>Bad list</li></ul>"; |
@@ -37,7 +53,8 @@ discard block |
||
| 37 | 53 | } |
| 38 | 54 | |
| 39 | 55 | |
| 40 | - public function getUserData() { |
|
| 56 | + public function getUserData() |
|
| 57 | + { |
|
| 41 | 58 | $client['ip'] = $_SERVER['REMOTE_ADDR']; |
| 42 | 59 | $client['ua'] = $_SERVER['HTTP_USER_AGENT']; |
| 43 | 60 | return $client; |
@@ -45,35 +62,42 @@ discard block |
||
| 45 | 62 | |
| 46 | 63 | # Returns true, install or interact when inside manager |
| 47 | 64 | // deprecated |
| 48 | - public function insideManager() { |
|
| 65 | + public function insideManager() |
|
| 66 | + { |
|
| 49 | 67 | $m= false; |
| 50 | 68 | if( defined('IN_MANAGER_MODE') && IN_MANAGER_MODE === true) { |
| 51 | 69 | $m= true; |
| 52 | - if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') |
|
| 53 | - $m= "interact"; |
|
| 54 | - else |
|
| 55 | - if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') |
|
| 56 | - $m= "install"; |
|
| 70 | + if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') { |
|
| 71 | + $m= "interact"; |
|
| 72 | + } else |
|
| 73 | + if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') { |
|
| 74 | + $m= "install"; |
|
| 75 | + } |
|
| 57 | 76 | } |
| 58 | 77 | return $m; |
| 59 | 78 | } |
| 60 | 79 | |
| 61 | 80 | // deprecated |
| 62 | - public function putChunk($chunkName) { // alias name >.< |
|
| 81 | + public function putChunk($chunkName) |
|
| 82 | + { |
|
| 83 | +// alias name >.< |
|
| 63 | 84 | global $modx; |
| 64 | 85 | return $modx->getChunk($chunkName); |
| 65 | 86 | } |
| 66 | 87 | |
| 67 | - public function getDocGroups() { |
|
| 88 | + public function getDocGroups() |
|
| 89 | + { |
|
| 68 | 90 | global $modx; |
| 69 | 91 | return $modx->getUserDocGroups(); |
| 70 | 92 | } // deprecated |
| 71 | 93 | |
| 72 | - public function changePassword($o, $n) { |
|
| 94 | + public function changePassword($o, $n) |
|
| 95 | + { |
|
| 73 | 96 | return changeWebUserPassword($o, $n); |
| 74 | 97 | } // deprecated |
| 75 | 98 | |
| 76 | - public function userLoggedIn() { |
|
| 99 | + public function userLoggedIn() |
|
| 100 | + { |
|
| 77 | 101 | global $modx; |
| 78 | 102 | $userdetails= array (); |
| 79 | 103 | if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) { |
@@ -96,18 +120,22 @@ discard block |
||
| 96 | 120 | } |
| 97 | 121 | } |
| 98 | 122 | |
| 99 | - public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) { |
|
| 123 | + public function getFormVars($method= "", $prefix= "", $trim= "", $REQUEST_METHOD) |
|
| 124 | + { |
|
| 100 | 125 | // function to retrieve form results into an associative array |
| 101 | 126 | global $modx; |
| 102 | 127 | $results= array (); |
| 103 | 128 | $method= strtoupper($method); |
| 104 | - if ($method == "") |
|
| 105 | - $method= $REQUEST_METHOD; |
|
| 106 | - if ($method == "POST") |
|
| 107 | - $method= & $_POST; |
|
| 108 | - elseif ($method == "GET") $method= & $_GET; |
|
| 109 | - else |
|
| 110 | - return false; |
|
| 129 | + if ($method == "") { |
|
| 130 | + $method= $REQUEST_METHOD; |
|
| 131 | + } |
|
| 132 | + if ($method == "POST") { |
|
| 133 | + $method= & $_POST; |
|
| 134 | + } elseif ($method == "GET") { |
|
| 135 | + $method= & $_GET; |
|
| 136 | + } else { |
|
| 137 | + return false; |
|
| 138 | + } |
|
| 111 | 139 | reset($method); |
| 112 | 140 | foreach ($method as $key => $value) { |
| 113 | 141 | if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) { |
@@ -115,10 +143,12 @@ discard block |
||
| 115 | 143 | $pieces= explode($prefix, $key, 2); |
| 116 | 144 | $key= $pieces[1]; |
| 117 | 145 | $results[$key]= $value; |
| 118 | - } else |
|
| 119 | - $results[$key]= $value; |
|
| 146 | + } else { |
|
| 147 | + $results[$key]= $value; |
|
| 148 | + } |
|
| 149 | + } elseif ($prefix == "") { |
|
| 150 | + $results[$key]= $value; |
|
| 120 | 151 | } |
| 121 | - elseif ($prefix == "") $results[$key]= $value; |
|
| 122 | 152 | } |
| 123 | 153 | return $results; |
| 124 | 154 | } |
@@ -129,7 +159,8 @@ discard block |
||
| 129 | 159 | * @param string $msg Message to show |
| 130 | 160 | * @param string $url URL to redirect to |
| 131 | 161 | */ |
| 132 | - public function webAlert($msg, $url= "") { |
|
| 162 | + public function webAlert($msg, $url= "") |
|
| 163 | + { |
|
| 133 | 164 | global $modx; |
| 134 | 165 | $msg= addslashes($modx->db->escape($msg)); |
| 135 | 166 | if (substr(strtolower($url), 0, 11) == "javascript:") { |
@@ -139,9 +170,9 @@ discard block |
||
| 139 | 170 | $act= ($url ? "window.location.href='" . addslashes($url) . "';" : ""); |
| 140 | 171 | } |
| 141 | 172 | $html= "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
| 142 | - if ($modx->isFrontend()) |
|
| 143 | - $modx->regClientScript($html); |
|
| 144 | - else { |
|
| 173 | + if ($modx->isFrontend()) { |
|
| 174 | + $modx->regClientScript($html); |
|
| 175 | + } else { |
|
| 145 | 176 | echo $html; |
| 146 | 177 | } |
| 147 | 178 | } |
@@ -13,27 +13,31 @@ discard block |
||
| 13 | 13 | public $dirCheckCount = 0; |
| 14 | 14 | |
| 15 | 15 | public function __construct() |
| 16 | - { |
|
| 16 | + { |
|
| 17 | 17 | global $modx; |
| 18 | 18 | |
| 19 | - if(!defined('MODX_BASE_PATH')) return false; |
|
| 19 | + if(!defined('MODX_BASE_PATH')) { |
|
| 20 | + return false; |
|
| 21 | + } |
|
| 20 | 22 | $this->exportstart = $this->get_mtime(); |
| 21 | 23 | $this->count = 0; |
| 22 | 24 | $this->setUrlMode(); |
| 23 | 25 | $this->generate_mode = 'crawl'; |
| 24 | 26 | $this->targetDir = $modx->config['base_path'] . 'temp/export'; |
| 25 | - if(!isset($this->total)) $this->getTotal(); |
|
| 27 | + if(!isset($this->total)) { |
|
| 28 | + $this->getTotal(); |
|
| 29 | + } |
|
| 26 | 30 | } |
| 27 | 31 | |
| 28 | 32 | public function setExportDir($dir) |
| 29 | - { |
|
| 33 | + { |
|
| 30 | 34 | $dir = str_replace('\\','/',$dir); |
| 31 | 35 | $dir = rtrim($dir, '/'); |
| 32 | 36 | $this->targetDir = $dir; |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | 39 | public function get_mtime() |
| 36 | - { |
|
| 40 | + { |
|
| 37 | 41 | $mtime = microtime(); |
| 38 | 42 | $mtime = explode(' ', $mtime); |
| 39 | 43 | $mtime = $mtime[1] + $mtime[0]; |
@@ -41,11 +45,10 @@ discard block |
||
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | public function setUrlMode() |
| 44 | - { |
|
| 48 | + { |
|
| 45 | 49 | global $modx; |
| 46 | 50 | |
| 47 | - if($modx->config['friendly_urls']==0) |
|
| 48 | - { |
|
| 51 | + if($modx->config['friendly_urls']==0) { |
|
| 49 | 52 | $modx->config['friendly_urls'] = 1; |
| 50 | 53 | $modx->config['use_alias_path'] = 1; |
| 51 | 54 | $modx->clearCache('full'); |
@@ -54,13 +57,12 @@ discard block |
||
| 54 | 57 | } |
| 55 | 58 | |
| 56 | 59 | public function getTotal($ignore_ids='', $noncache='0') |
| 57 | - { |
|
| 60 | + { |
|
| 58 | 61 | global $modx; |
| 59 | 62 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 60 | 63 | |
| 61 | 64 | $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids))); |
| 62 | - if(count($ignore_ids)>0) |
|
| 63 | - { |
|
| 65 | + if(count($ignore_ids)>0) { |
|
| 64 | 66 | $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')"; |
| 65 | 67 | } else { |
| 66 | 68 | $ignore_ids = ''; |
@@ -76,67 +78,80 @@ discard block |
||
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | public function removeDirectoryAll($directory='') |
| 79 | - { |
|
| 81 | + { |
|
| 80 | 82 | $rs = false; |
| 81 | - if(empty($directory)) $directory = $this->targetDir; |
|
| 83 | + if(empty($directory)) { |
|
| 84 | + $directory = $this->targetDir; |
|
| 85 | + } |
|
| 82 | 86 | $directory = rtrim($directory,'/'); |
| 83 | 87 | // if the path is not valid or is not a directory ... |
| 84 | - if(empty($directory)) return false; |
|
| 85 | - if(strpos($directory,MODX_BASE_PATH)===false) return $rs; |
|
| 88 | + if(empty($directory)) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + if(strpos($directory,MODX_BASE_PATH)===false) { |
|
| 92 | + return $rs; |
|
| 93 | + } |
|
| 86 | 94 | |
| 87 | - if(!is_dir($directory)) return $rs; |
|
| 88 | - elseif(!is_readable($directory)) return $rs; |
|
| 89 | - else |
|
| 90 | - { |
|
| 95 | + if(!is_dir($directory)) { |
|
| 96 | + return $rs; |
|
| 97 | + } elseif(!is_readable($directory)) { |
|
| 98 | + return $rs; |
|
| 99 | + } else { |
|
| 91 | 100 | $files = glob($directory . '/*'); |
| 92 | - if(!empty($files)) |
|
| 93 | - { |
|
| 94 | - foreach($files as $path) |
|
| 95 | - { |
|
| 101 | + if(!empty($files)) { |
|
| 102 | + foreach($files as $path) { |
|
| 96 | 103 | $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path); |
| 97 | 104 | } |
| 98 | 105 | } |
| 99 | 106 | } |
| 100 | - if($directory !== $this->targetDir) $rs = rmdir($directory); |
|
| 107 | + if($directory !== $this->targetDir) { |
|
| 108 | + $rs = rmdir($directory); |
|
| 109 | + } |
|
| 101 | 110 | |
| 102 | 111 | return $rs; |
| 103 | 112 | } |
| 104 | 113 | |
| 105 | 114 | public function makeFile($docid, $filepath) |
| 106 | - { |
|
| 115 | + { |
|
| 107 | 116 | global $modx,$_lang; |
| 108 | 117 | $file_permission = octdec($modx->config['new_file_permissions']); |
| 109 | - if($this->generate_mode==='direct') |
|
| 110 | - { |
|
| 118 | + if($this->generate_mode==='direct') { |
|
| 111 | 119 | $back_lang = $_lang; |
| 112 | 120 | $src = $modx->executeParser($docid); |
| 113 | 121 | |
| 114 | 122 | $_lang = $back_lang; |
| 123 | + } else { |
|
| 124 | + $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
| 115 | 125 | } |
| 116 | - else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}"); |
|
| 117 | 126 | |
| 118 | 127 | |
| 119 | - if($src !== false) |
|
| 120 | - { |
|
| 121 | - if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src); |
|
| 128 | + if($src !== false) { |
|
| 129 | + if($this->repl_before!==$this->repl_after) { |
|
| 130 | + $src = str_replace($this->repl_before,$this->repl_after,$src); |
|
| 131 | + } |
|
| 122 | 132 | $result = file_put_contents($filepath,$src); |
| 123 | - if($result!==false) @chmod($filepath, $file_permission); |
|
| 133 | + if($result!==false) { |
|
| 134 | + @chmod($filepath, $file_permission); |
|
| 135 | + } |
|
| 124 | 136 | |
| 125 | - if($result !== false) return 'success'; |
|
| 126 | - else return 'failed_no_write'; |
|
| 137 | + if($result !== false) { |
|
| 138 | + return 'success'; |
|
| 139 | + } else { |
|
| 140 | + return 'failed_no_write'; |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + return 'failed_no_retrieve'; |
|
| 127 | 144 | } |
| 128 | - else return 'failed_no_retrieve'; |
|
| 129 | 145 | } |
| 130 | 146 | |
| 131 | 147 | public function getFileName($docid, $alias='', $prefix, $suffix) |
| 132 | - { |
|
| 148 | + { |
|
| 133 | 149 | global $modx; |
| 134 | 150 | |
| 135 | - if($alias==='') $filename = $prefix.$docid.$suffix; |
|
| 136 | - else |
|
| 137 | - { |
|
| 138 | - if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) |
|
| 139 | - { |
|
| 151 | + if($alias==='') { |
|
| 152 | + $filename = $prefix.$docid.$suffix; |
|
| 153 | + } else { |
|
| 154 | + if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) { |
|
| 140 | 155 | $suffix = ''; |
| 141 | 156 | } |
| 142 | 157 | $filename = $prefix.$alias.$suffix; |
@@ -145,7 +160,7 @@ discard block |
||
| 145 | 160 | } |
| 146 | 161 | |
| 147 | 162 | public function run($parent=0) |
| 148 | - { |
|
| 163 | + { |
|
| 149 | 164 | global $_lang; |
| 150 | 165 | global $modx; |
| 151 | 166 | |
@@ -187,24 +202,20 @@ discard block |
||
| 187 | 202 | $ph = array(); |
| 188 | 203 | $ph['total'] = $this->total; |
| 189 | 204 | $folder_permission = octdec($modx->config['new_folder_permissions']); |
| 190 | - while($row = $modx->db->getRow($rs)) |
|
| 191 | - { |
|
| 205 | + while($row = $modx->db->getRow($rs)) { |
|
| 192 | 206 | $this->count++; |
| 193 | 207 | $filename = ''; |
| 194 | 208 | $row['count'] = $this->count; |
| 195 | 209 | $row['url'] = $modx->makeUrl($row['id']); |
| 196 | 210 | |
| 197 | - if (!$row['wasNull']) |
|
| 198 | - { // needs writing a document |
|
| 211 | + if (!$row['wasNull']) { |
|
| 212 | +// needs writing a document |
|
| 199 | 213 | $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix); |
| 200 | 214 | $filename = $dirpath.$docname; |
| 201 | - if (!is_file($filename)) |
|
| 202 | - { |
|
| 203 | - if($row['published']==='1') |
|
| 204 | - { |
|
| 215 | + if (!is_file($filename)) { |
|
| 216 | + if($row['published']==='1') { |
|
| 205 | 217 | $status = $this->makeFile($row['id'], $filename); |
| 206 | - switch($status) |
|
| 207 | - { |
|
| 218 | + switch($status) { |
|
| 208 | 219 | case 'failed_no_write' : |
| 209 | 220 | $row['status'] = $msg_failed_no_write; |
| 210 | 221 | break; |
@@ -214,34 +225,38 @@ discard block |
||
| 214 | 225 | default: |
| 215 | 226 | $row['status'] = $msg_success; |
| 216 | 227 | } |
| 228 | + } else { |
|
| 229 | + $row['status'] = $msg_failed_no_retrieve; |
|
| 217 | 230 | } |
| 218 | - else $row['status'] = $msg_failed_no_retrieve; |
|
| 231 | + } else { |
|
| 232 | + $row['status'] = $msg_success_skip_doc; |
|
| 219 | 233 | } |
| 220 | - else $row['status'] = $msg_success_skip_doc; |
|
| 221 | 234 | $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row); |
| 222 | - } |
|
| 223 | - else |
|
| 224 | - { |
|
| 235 | + } else { |
|
| 225 | 236 | $row['status'] = $msg_success_skip_dir; |
| 226 | 237 | $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row); |
| 227 | 238 | } |
| 228 | - if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) |
|
| 229 | - { // needs making a folder |
|
| 239 | + if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) { |
|
| 240 | +// needs making a folder |
|
| 230 | 241 | $end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id']; |
| 231 | 242 | $dir_path = $dirpath . $end_dir; |
| 232 | - if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE; |
|
| 233 | - if (!is_dir($dir_path)) |
|
| 234 | - { |
|
| 235 | - if (is_file($dir_path)) @unlink($dir_path); |
|
| 243 | + if(strpos($dir_path,MODX_BASE_PATH)===false) { |
|
| 244 | + return FALSE; |
|
| 245 | + } |
|
| 246 | + if (!is_dir($dir_path)) { |
|
| 247 | + if (is_file($dir_path)) { |
|
| 248 | + @unlink($dir_path); |
|
| 249 | + } |
|
| 236 | 250 | mkdir($dir_path); |
| 237 | 251 | @chmod($dir_path, $folder_permission); |
| 238 | 252 | |
| 239 | 253 | } |
| 240 | 254 | |
| 241 | 255 | |
| 242 | - if($modx->config['make_folders']==='1' && $row['published']==='1') |
|
| 243 | - { |
|
| 244 | - if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html'); |
|
| 256 | + if($modx->config['make_folders']==='1' && $row['published']==='1') { |
|
| 257 | + if( ! empty($filename) && is_file($filename)) { |
|
| 258 | + rename($filename,$dir_path . '/index.html'); |
|
| 259 | + } |
|
| 245 | 260 | } |
| 246 | 261 | $this->targetDir = $dir_path; |
| 247 | 262 | $this->run($row['id']); |
@@ -252,7 +267,9 @@ discard block |
||
| 252 | 267 | |
| 253 | 268 | public function curl_get_contents($url, $timeout = 30 ) |
| 254 | 269 | { |
| 255 | - if(!function_exists('curl_init')) return @file_get_contents($url); |
|
| 270 | + if(!function_exists('curl_init')) { |
|
| 271 | + return @file_get_contents($url); |
|
| 272 | + } |
|
| 256 | 273 | |
| 257 | 274 | $ch = curl_init(); |
| 258 | 275 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -269,8 +286,7 @@ discard block |
||
| 269 | 286 | |
| 270 | 287 | public function parsePlaceholder($tpl,$ph=array()) |
| 271 | 288 | { |
| 272 | - foreach($ph as $k=>$v) |
|
| 273 | - { |
|
| 289 | + foreach($ph as $k=>$v) { |
|
| 274 | 290 | $k = "[+{$k}+]"; |
| 275 | 291 | $tpl = str_replace($k,$v,$tpl); |
| 276 | 292 | } |