@@ -3,12 +3,12 @@ discard block |
||
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | 5 | if(!$modx->hasPermission('delete_module')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
| 10 | 10 | if($id==0) { |
| 11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Set the item name for logger |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // invoke OnBeforeModFormDelete event |
| 19 | 19 | $modx->invokeEvent("OnBeforeModFormDelete", |
| 20 | - array( |
|
| 21 | - "id" => $id |
|
| 22 | - )); |
|
| 20 | + array( |
|
| 21 | + "id" => $id |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | 24 | // delete the module. |
| 25 | 25 | $modx->db->delete($modx->getFullTableName('site_modules'), "id='{$id}'"); |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // invoke OnModFormDelete event |
| 34 | 34 | $modx->invokeEvent("OnModFormDelete", |
| 35 | - array( |
|
| 36 | - "id" => $id |
|
| 37 | - )); |
|
| 35 | + array( |
|
| 36 | + "id" => $id |
|
| 37 | + )); |
|
| 38 | 38 | |
| 39 | 39 | // empty cache |
| 40 | 40 | $modx->clearCache('full'); |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('delete_module')) { |
|
| 5 | +if (!$modx->hasPermission('delete_module')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
| 10 | -if($id==0) { |
|
| 9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 10 | +if ($id == 0) { |
|
| 11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -40,5 +40,5 @@ discard block |
||
| 40 | 40 | $modx->clearCache('full'); |
| 41 | 41 | |
| 42 | 42 | // finished emptying cache - redirect |
| 43 | -$header="Location: index.php?a=106&r=2"; |
|
| 43 | +$header = "Location: index.php?a=106&r=2"; |
|
| 44 | 44 | header($header); |
@@ -1,13 +1,13 @@ 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 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes |
| 7 | 7 | |
| 8 | 8 | if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
|
| 9 | - // seems to be a new install - send the user to the configuration page |
|
| 10 | - exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
|
|
| 9 | + // seems to be a new install - send the user to the configuration page |
|
| 10 | + exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
|
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // set placeholders |
@@ -17,70 +17,70 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // setup message info |
| 19 | 19 | if($modx->hasPermission('messages')) {
|
| 20 | - include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
|
| 21 | - $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
|
| 22 | - $_SESSION['nrnewmessages'] = $nrnewmessages; |
|
| 23 | - |
|
| 24 | - $msg = array(); |
|
| 25 | - $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
|
|
| 26 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : ''; |
|
| 27 | - $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold"> <a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
|
|
| 28 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0'; |
|
| 29 | - $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); |
|
| 30 | - $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
|
|
| 31 | - $ph['MessageInfo'] = implode("\n", $msg);
|
|
| 20 | + include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
|
| 21 | + $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
|
| 22 | + $_SESSION['nrnewmessages'] = $nrnewmessages; |
|
| 23 | + |
|
| 24 | + $msg = array(); |
|
| 25 | + $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
|
|
| 26 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : ''; |
|
| 27 | + $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold"> <a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
|
|
| 28 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0'; |
|
| 29 | + $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); |
|
| 30 | + $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
|
|
| 31 | + $ph['MessageInfo'] = implode("\n", $msg);
|
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // setup icons |
| 35 | 35 | if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
|
| 36 | - $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
|
| 37 | - $ph['SecurityIcon'] = wrapIcon($icon, 75); |
|
| 36 | + $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
|
| 37 | + $ph['SecurityIcon'] = wrapIcon($icon, 75); |
|
| 38 | 38 | } |
| 39 | 39 | if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
|
| 40 | - $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
|
| 41 | - $ph['WebUserIcon'] = wrapIcon($icon, 99); |
|
| 40 | + $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
|
| 41 | + $ph['WebUserIcon'] = wrapIcon($icon, 99); |
|
| 42 | 42 | } |
| 43 | 43 | if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
|
| 44 | - $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
|
| 45 | - $ph['ModulesIcon'] = wrapIcon($icon, 106); |
|
| 44 | + $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
|
| 45 | + $ph['ModulesIcon'] = wrapIcon($icon, 106); |
|
| 46 | 46 | } |
| 47 | 47 | if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
|
| 48 | - $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
|
| 49 | - $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
|
| 48 | + $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
|
| 49 | + $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
|
| 50 | 50 | } |
| 51 | 51 | if($modx->hasPermission('bk_manager')) {
|
| 52 | - $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
|
| 53 | - $ph['BackupIcon'] = wrapIcon($icon, 93); |
|
| 52 | + $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
|
| 53 | + $ph['BackupIcon'] = wrapIcon($icon, 93); |
|
| 54 | 54 | } |
| 55 | 55 | if($modx->hasPermission('help')) {
|
| 56 | - $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
|
| 57 | - $ph['HelpIcon'] = wrapIcon($icon, 9); |
|
| 56 | + $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
|
| 57 | + $ph['HelpIcon'] = wrapIcon($icon, 9); |
|
| 58 | 58 | } |
| 59 | 59 | // do some config checks |
| 60 | 60 | if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
|
| 61 | - include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
|
| 62 | - if($config_check_results != $_lang['configcheck_ok']) {
|
|
| 63 | - $ph['config_check_results'] = $config_check_results; |
|
| 64 | - $ph['config_display'] = 'block'; |
|
| 65 | - } else {
|
|
| 66 | - $ph['config_display'] = 'none'; |
|
| 67 | - } |
|
| 61 | + include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
|
| 62 | + if($config_check_results != $_lang['configcheck_ok']) {
|
|
| 63 | + $ph['config_check_results'] = $config_check_results; |
|
| 64 | + $ph['config_display'] = 'block'; |
|
| 65 | + } else {
|
|
| 66 | + $ph['config_display'] = 'none'; |
|
| 67 | + } |
|
| 68 | 68 | } else {
|
| 69 | - $ph['config_display'] = 'none'; |
|
| 69 | + $ph['config_display'] = 'none'; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check logout-reminder |
| 73 | 73 | if(isset($_SESSION['show_logout_reminder'])) {
|
| 74 | - switch($_SESSION['show_logout_reminder']['type']) {
|
|
| 75 | - case 'logout_reminder': |
|
| 76 | - $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
|
| 77 | - $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
|
|
| 78 | - break; |
|
| 79 | - } |
|
| 80 | - $ph['show_logout_reminder'] = 'block'; |
|
| 81 | - unset($_SESSION['show_logout_reminder']); |
|
| 74 | + switch($_SESSION['show_logout_reminder']['type']) {
|
|
| 75 | + case 'logout_reminder': |
|
| 76 | + $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
|
| 77 | + $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
|
|
| 78 | + break; |
|
| 79 | + } |
|
| 80 | + $ph['show_logout_reminder'] = 'block'; |
|
| 81 | + unset($_SESSION['show_logout_reminder']); |
|
| 82 | 82 | } else {
|
| 83 | - $ph['show_logout_reminder'] = 'none'; |
|
| 83 | + $ph['show_logout_reminder'] = 'none'; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Check multiple sessions |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | $nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>'; |
| 129 | 129 | |
| 130 | 130 | $ph['UserInfo'] = $modx->parseText($tpl, array( |
| 131 | - 'username' => $modx->getLoginUserName(), |
|
| 132 | - 'role' => $_SESSION['mgrPermissions']['name'], |
|
| 133 | - 'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time), |
|
| 134 | - 'logincount' => $_SESSION['mgrLogincount'] + 1, |
|
| 135 | - 'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages) |
|
| 131 | + 'username' => $modx->getLoginUserName(), |
|
| 132 | + 'role' => $_SESSION['mgrPermissions']['name'], |
|
| 133 | + 'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time), |
|
| 134 | + 'logincount' => $_SESSION['mgrLogincount'] + 1, |
|
| 135 | + 'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages) |
|
| 136 | 136 | )); |
| 137 | 137 | |
| 138 | 138 | $from = array(); |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
|
| 142 | 142 | |
| 143 | 143 | if($modx->db->getRecordCount($rs) < 1) {
|
| 144 | - $html = '<p>[%no_active_users_found%]</p>'; |
|
| 144 | + $html = '<p>[%no_active_users_found%]</p>'; |
|
| 145 | 145 | } else {
|
| 146 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
| 147 | - $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
|
| 148 | - $ph['now'] = strftime('%H:%M:%S', $now);
|
|
| 149 | - $timetocheck = ($now - (60 * 20)); //+$server_offset_time; |
|
| 150 | - $html = ' |
|
| 146 | + include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
| 147 | + $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
|
| 148 | + $ph['now'] = strftime('%H:%M:%S', $now);
|
|
| 149 | + $timetocheck = ($now - (60 * 20)); //+$server_offset_time; |
|
| 150 | + $html = ' |
|
| 151 | 151 | <div class="card-body"> |
| 152 | 152 | [%onlineusers_message%] |
| 153 | 153 | <b>[+now+]</b>): |
@@ -165,33 +165,33 @@ discard block |
||
| 165 | 165 | </thead> |
| 166 | 166 | <tbody>'; |
| 167 | 167 | |
| 168 | - $userList = array(); |
|
| 169 | - $userCount = array(); |
|
| 170 | - // Create userlist with session-count first before output |
|
| 171 | - while($activeusers = $modx->db->getRow($rs)) {
|
|
| 172 | - $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
|
| 173 | - |
|
| 174 | - $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
|
| 175 | - $webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" /> ' : ''; |
|
| 176 | - $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip']; |
|
| 177 | - $currentaction = getAction($activeusers['action'], $activeusers['id']); |
|
| 178 | - $userList[] = array( |
|
| 179 | - $idle, |
|
| 180 | - '', |
|
| 181 | - $activeusers['username'], |
|
| 182 | - $webicon, |
|
| 183 | - abs($activeusers['internalKey']), |
|
| 184 | - $ip, |
|
| 185 | - strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
|
|
| 186 | - $currentaction |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - foreach($userList as $params) {
|
|
| 190 | - $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
|
| 191 | - $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
|
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $html .= ' |
|
| 168 | + $userList = array(); |
|
| 169 | + $userCount = array(); |
|
| 170 | + // Create userlist with session-count first before output |
|
| 171 | + while($activeusers = $modx->db->getRow($rs)) {
|
|
| 172 | + $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
|
| 173 | + |
|
| 174 | + $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
|
| 175 | + $webicon = $activeusers['internalKey'] < 0 ? '<img src="[&tree_globe&]" alt="Web user" /> ' : ''; |
|
| 176 | + $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip']; |
|
| 177 | + $currentaction = getAction($activeusers['action'], $activeusers['id']); |
|
| 178 | + $userList[] = array( |
|
| 179 | + $idle, |
|
| 180 | + '', |
|
| 181 | + $activeusers['username'], |
|
| 182 | + $webicon, |
|
| 183 | + abs($activeusers['internalKey']), |
|
| 184 | + $ip, |
|
| 185 | + strftime('%H:%M:%S', $activeusers['lasthit'] + $server_offset_time),
|
|
| 186 | + $currentaction |
|
| 187 | + ); |
|
| 188 | + } |
|
| 189 | + foreach($userList as $params) {
|
|
| 190 | + $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
|
| 191 | + $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
|
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $html .= ' |
|
| 195 | 195 | </tbody> |
| 196 | 196 | </table> |
| 197 | 197 | </div> |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | // invoke event OnManagerWelcomePrerender |
| 233 | 233 | $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
|
| 234 | 234 | if(is_array($evtOut)) {
|
| 235 | - $output = implode('', $evtOut);
|
|
| 236 | - $ph['OnManagerWelcomePrerender'] = $output; |
|
| 235 | + $output = implode('', $evtOut);
|
|
| 236 | + $ph['OnManagerWelcomePrerender'] = $output; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $widgets['welcome'] = array( |
| 240 | - 'menuindex' => '10', |
|
| 241 | - 'id' => 'welcome', |
|
| 242 | - 'cols' => 'col-sm-6', |
|
| 243 | - 'icon' => 'fa-home', |
|
| 244 | - 'title' => '[%welcome_title%]', |
|
| 245 | - 'body' => ' |
|
| 240 | + 'menuindex' => '10', |
|
| 241 | + 'id' => 'welcome', |
|
| 242 | + 'cols' => 'col-sm-6', |
|
| 243 | + 'icon' => 'fa-home', |
|
| 244 | + 'title' => '[%welcome_title%]', |
|
| 245 | + 'body' => ' |
|
| 246 | 246 | <div class="wm_buttons card-body"> |
| 247 | 247 | <!--@IF:[[#hasPermission?key=new_user]] OR [[#hasPermission?key=edit_user]]--> |
| 248 | 248 | <span class="wm_button"> |
@@ -320,25 +320,25 @@ discard block |
||
| 320 | 320 | </table> |
| 321 | 321 | </div> |
| 322 | 322 | ', |
| 323 | - 'hide'=>'0' |
|
| 323 | + 'hide'=>'0' |
|
| 324 | 324 | ); |
| 325 | 325 | $widgets['onlineinfo'] = array( |
| 326 | - 'menuindex' => '20', |
|
| 327 | - 'id' => 'onlineinfo', |
|
| 328 | - 'cols' => 'col-sm-6', |
|
| 329 | - 'icon' => 'fa-user', |
|
| 330 | - 'title' => '[%onlineusers_title%]', |
|
| 331 | - 'body' => '<div class="userstable">[+OnlineInfo+]</div>', |
|
| 332 | - 'hide'=>'0' |
|
| 326 | + 'menuindex' => '20', |
|
| 327 | + 'id' => 'onlineinfo', |
|
| 328 | + 'cols' => 'col-sm-6', |
|
| 329 | + 'icon' => 'fa-user', |
|
| 330 | + 'title' => '[%onlineusers_title%]', |
|
| 331 | + 'body' => '<div class="userstable">[+OnlineInfo+]</div>', |
|
| 332 | + 'hide'=>'0' |
|
| 333 | 333 | ); |
| 334 | 334 | $widgets['recentinfo'] = array( |
| 335 | - 'menuindex' => '30', |
|
| 336 | - 'id' => 'modxrecent_widget', |
|
| 337 | - 'cols' => 'col-sm-12', |
|
| 338 | - 'icon' => 'fa-pencil-square-o', |
|
| 339 | - 'title' => '[%activity_title%]', |
|
| 340 | - 'body' => '<div class="widget-stage">[+RecentInfo+]</div>', |
|
| 341 | - 'hide'=>'0' |
|
| 335 | + 'menuindex' => '30', |
|
| 336 | + 'id' => 'modxrecent_widget', |
|
| 337 | + 'cols' => 'col-sm-12', |
|
| 338 | + 'icon' => 'fa-pencil-square-o', |
|
| 339 | + 'title' => '[%activity_title%]', |
|
| 340 | + 'body' => '<div class="widget-stage">[+RecentInfo+]</div>', |
|
| 341 | + 'hide'=>'0' |
|
| 342 | 342 | ); |
| 343 | 343 | if ($modx->config['rss_url_news']) {
|
| 344 | 344 | $widgets['news'] = array( |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | // invoke OnManagerWelcomeHome event |
| 367 | 367 | $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
|
| 368 | 368 | if(is_array($sitewidgets)) {
|
| 369 | - $newwidgets = array(); |
|
| 369 | + $newwidgets = array(); |
|
| 370 | 370 | foreach($sitewidgets as $widget){
|
| 371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); |
| 372 | 372 | } |
@@ -374,21 +374,21 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | usort($widgets, function ($a, $b) {
|
| 377 | - return $a['menuindex'] - $b['menuindex']; |
|
| 377 | + return $a['menuindex'] - $b['menuindex']; |
|
| 378 | 378 | }); |
| 379 | 379 | |
| 380 | 380 | $tpl = getTplWidget(); |
| 381 | 381 | $output = ''; |
| 382 | 382 | foreach($widgets as $widget) {
|
| 383 | - if ($widget['hide'] != '1'){
|
|
| 384 | - $output .= $modx->parseText($tpl, $widget); |
|
| 385 | - } |
|
| 383 | + if ($widget['hide'] != '1'){
|
|
| 384 | + $output .= $modx->parseText($tpl, $widget); |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | $ph['widgets'] = $output; |
| 388 | 388 | |
| 389 | 389 | // load template |
| 390 | 390 | if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
|
| 391 | - $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
|
| 391 | + $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $target = $modx->config['manager_welcome_tpl']; |
@@ -396,27 +396,27 @@ discard block |
||
| 396 | 396 | $target = $modx->mergeSettingsContent($target); |
| 397 | 397 | |
| 398 | 398 | if(substr($target, 0, 1) === '@') {
|
| 399 | - if(substr($target, 0, 6) === '@CHUNK') {
|
|
| 400 | - $content = $modx->getChunk(trim(substr($target, 7))); |
|
| 401 | - } elseif(substr($target, 0, 5) === '@FILE') {
|
|
| 402 | - $content = file_get_contents(trim(substr($target, 6))); |
|
| 403 | - } else {
|
|
| 404 | - $content = ''; |
|
| 405 | - } |
|
| 399 | + if(substr($target, 0, 6) === '@CHUNK') {
|
|
| 400 | + $content = $modx->getChunk(trim(substr($target, 7))); |
|
| 401 | + } elseif(substr($target, 0, 5) === '@FILE') {
|
|
| 402 | + $content = file_get_contents(trim(substr($target, 6))); |
|
| 403 | + } else {
|
|
| 404 | + $content = ''; |
|
| 405 | + } |
|
| 406 | 406 | } else {
|
| 407 | - $chunk = $modx->getChunk($target); |
|
| 408 | - if($chunk !== false && !empty($chunk)) {
|
|
| 409 | - $content = $chunk; |
|
| 410 | - } elseif(is_file(MODX_BASE_PATH . $target)) {
|
|
| 411 | - $content = file_get_contents(MODX_BASE_PATH . $target); |
|
| 412 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
|
|
| 413 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
|
| 414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
| 415 | - {
|
|
| 416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
| 417 | - } else {
|
|
| 418 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
|
| 419 | - } |
|
| 407 | + $chunk = $modx->getChunk($target); |
|
| 408 | + if($chunk !== false && !empty($chunk)) {
|
|
| 409 | + $content = $chunk; |
|
| 410 | + } elseif(is_file(MODX_BASE_PATH . $target)) {
|
|
| 411 | + $content = file_get_contents(MODX_BASE_PATH . $target); |
|
| 412 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
|
|
| 413 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
|
| 414 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
| 415 | + {
|
|
| 416 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
| 417 | + } else {
|
|
| 418 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
|
| 419 | + } |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // merge placeholders |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | $content = $modx->mergeSettingsContent($content); |
| 425 | 425 | $content = $modx->parseText($content, $ph); |
| 426 | 426 | if(strpos($content, '[+') !== false) {
|
| 427 | - $modx->toPlaceholders($ph); |
|
| 428 | - $content = $modx->mergePlaceholderContent($content); |
|
| 427 | + $modx->toPlaceholders($ph); |
|
| 428 | + $content = $modx->mergePlaceholderContent($content); |
|
| 429 | 429 | } |
| 430 | 430 | $content = $modx->parseDocumentSource($content); |
| 431 | 431 | $content = $modx->parseText($content, $_lang, '[%', '%]'); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $content = $modx->cleanUpMODXTags($content); //cleanup |
| 434 | 434 | |
| 435 | 435 | if($js = $modx->getRegisteredClientScripts()) {
|
| 436 | - $content .= $js; |
|
| 436 | + $content .= $js; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | echo $content; |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> |
| 444 | 444 | //</span> |
| 445 | 445 | function getTplWidget() { // recent document info
|
| 446 | - return ' |
|
| 446 | + return ' |
|
| 447 | 447 | <div class="[+cols+]" id="[+id+]"> |
| 448 | 448 | <div class="card"[+cardAttr+]> |
| 449 | 449 | <div class="card-header"[+headAttr+]> <i class="fa [+icon+]"></i> [+title+] </div> |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | function getRecentInfo() { // recent document info
|
| 457 | - global $modx; |
|
| 457 | + global $modx; |
|
| 458 | 458 | |
| 459 | - $modx->addSnippet('recentInfoList', 'getRecentInfoList');
|
|
| 459 | + $modx->addSnippet('recentInfoList', 'getRecentInfoList');
|
|
| 460 | 460 | |
| 461 | - $html = ' |
|
| 461 | + $html = ' |
|
| 462 | 462 | <div class="table-responsive"> |
| 463 | 463 | <table class="table data"> |
| 464 | 464 | <thead> |
@@ -476,96 +476,96 @@ discard block |
||
| 476 | 476 | </table> |
| 477 | 477 | </div> |
| 478 | 478 | '; |
| 479 | - return $html; |
|
| 479 | + return $html; |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | function getRecentInfoList() {
|
| 483 | - global $modx; |
|
| 484 | - |
|
| 485 | - $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
|
|
| 486 | - |
|
| 487 | - if($modx->db->getRecordCount($rs) < 1) {
|
|
| 488 | - return '<tr><td>[%no_activity_message%]</td></tr>'; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - $tpl = getRecentInfoRowTpl(); |
|
| 492 | - |
|
| 493 | - $btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> '; |
|
| 494 | - $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
|
| 495 | - |
|
| 496 | - $output = array(); |
|
| 497 | - while($ph = $modx->db->getRow($rs)) {
|
|
| 498 | - $docid = $ph['id']; |
|
| 499 | - $_ = $modx->getUserInfo($ph['editedby']); |
|
| 500 | - $ph['username'] = $_['username']; |
|
| 501 | - |
|
| 502 | - if($ph['deleted'] == 1) {
|
|
| 503 | - $ph['status'] = 'deleted text-danger'; |
|
| 504 | - } elseif($ph['published'] == 0) {
|
|
| 505 | - $ph['status'] = 'unpublished font-italic text-muted'; |
|
| 506 | - } else {
|
|
| 507 | - $ph['status'] = 'published'; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - if($modx->hasPermission('edit_document')) {
|
|
| 511 | - $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
|
|
| 512 | - } else {
|
|
| 513 | - $ph['edit_btn'] = ''; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : ''; |
|
| 517 | - $ph['preview_btn'] = str_replace(array( |
|
| 518 | - '[+id+]', |
|
| 519 | - '[+preview_disabled+]' |
|
| 520 | - ), array( |
|
| 521 | - $docid, |
|
| 522 | - $preview_disabled |
|
| 523 | - ), $btntpl['preview_btn']); |
|
| 524 | - |
|
| 525 | - if($modx->hasPermission('delete_document')) {
|
|
| 526 | - if($ph['deleted'] == 0) {
|
|
| 527 | - $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
|
| 528 | - } else {
|
|
| 529 | - $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
|
| 530 | - } |
|
| 531 | - $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
|
|
| 532 | - } else {
|
|
| 533 | - $ph['delete_btn'] = ''; |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - if($ph['deleted'] == 1 && $ph['published'] == 0) {
|
|
| 537 | - $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
|
| 538 | - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
|
|
| 539 | - $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
|
| 540 | - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
|
|
| 541 | - $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
|
| 542 | - } else {
|
|
| 543 | - $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
|
| 544 | - } |
|
| 545 | - $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
|
|
| 546 | - |
|
| 547 | - $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
|
|
| 548 | - |
|
| 549 | - if($ph['longtitle'] == '') {
|
|
| 550 | - $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
|
| 551 | - } |
|
| 552 | - if($ph['description'] == '') {
|
|
| 553 | - $ph['description'] = '(<i>[%not_set%]</i>)'; |
|
| 554 | - } |
|
| 555 | - if($ph['introtext'] == '') {
|
|
| 556 | - $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
|
| 557 | - } |
|
| 558 | - if($ph['alias'] == '') {
|
|
| 559 | - $ph['alias'] = '(<i>[%not_set%]</i>)'; |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - $output[] = $modx->parseText($tpl, $ph); |
|
| 563 | - } |
|
| 564 | - return implode("\n", $output);
|
|
| 483 | + global $modx; |
|
| 484 | + |
|
| 485 | + $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
|
|
| 486 | + |
|
| 487 | + if($modx->db->getRecordCount($rs) < 1) {
|
|
| 488 | + return '<tr><td>[%no_activity_message%]</td></tr>'; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + $tpl = getRecentInfoRowTpl(); |
|
| 492 | + |
|
| 493 | + $btntpl['edit'] = '<a title="[%edit_resource%]" href="index.php?a=27&id=[+id+]" target="main"><i class="fa fa-edit fa-fw"></i></a> '; |
|
| 494 | + $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
|
| 495 | + |
|
| 496 | + $output = array(); |
|
| 497 | + while($ph = $modx->db->getRow($rs)) {
|
|
| 498 | + $docid = $ph['id']; |
|
| 499 | + $_ = $modx->getUserInfo($ph['editedby']); |
|
| 500 | + $ph['username'] = $_['username']; |
|
| 501 | + |
|
| 502 | + if($ph['deleted'] == 1) {
|
|
| 503 | + $ph['status'] = 'deleted text-danger'; |
|
| 504 | + } elseif($ph['published'] == 0) {
|
|
| 505 | + $ph['status'] = 'unpublished font-italic text-muted'; |
|
| 506 | + } else {
|
|
| 507 | + $ph['status'] = 'published'; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + if($modx->hasPermission('edit_document')) {
|
|
| 511 | + $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
|
|
| 512 | + } else {
|
|
| 513 | + $ph['edit_btn'] = ''; |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : ''; |
|
| 517 | + $ph['preview_btn'] = str_replace(array( |
|
| 518 | + '[+id+]', |
|
| 519 | + '[+preview_disabled+]' |
|
| 520 | + ), array( |
|
| 521 | + $docid, |
|
| 522 | + $preview_disabled |
|
| 523 | + ), $btntpl['preview_btn']); |
|
| 524 | + |
|
| 525 | + if($modx->hasPermission('delete_document')) {
|
|
| 526 | + if($ph['deleted'] == 0) {
|
|
| 527 | + $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
|
| 528 | + } else {
|
|
| 529 | + $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
|
| 530 | + } |
|
| 531 | + $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
|
|
| 532 | + } else {
|
|
| 533 | + $ph['delete_btn'] = ''; |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + if($ph['deleted'] == 1 && $ph['published'] == 0) {
|
|
| 537 | + $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
|
| 538 | + } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
|
|
| 539 | + $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
|
| 540 | + } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
|
|
| 541 | + $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
|
| 542 | + } else {
|
|
| 543 | + $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
|
| 544 | + } |
|
| 545 | + $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
|
|
| 546 | + |
|
| 547 | + $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
|
|
| 548 | + |
|
| 549 | + if($ph['longtitle'] == '') {
|
|
| 550 | + $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
|
| 551 | + } |
|
| 552 | + if($ph['description'] == '') {
|
|
| 553 | + $ph['description'] = '(<i>[%not_set%]</i>)'; |
|
| 554 | + } |
|
| 555 | + if($ph['introtext'] == '') {
|
|
| 556 | + $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
|
| 557 | + } |
|
| 558 | + if($ph['alias'] == '') {
|
|
| 559 | + $ph['alias'] = '(<i>[%not_set%]</i>)'; |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + $output[] = $modx->parseText($tpl, $ph); |
|
| 563 | + } |
|
| 564 | + return implode("\n", $output);
|
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | function getRecentInfoRowTpl() {
|
| 568 | - $tpl = ' |
|
| 568 | + $tpl = ' |
|
| 569 | 569 | <tr> |
| 570 | 570 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> |
| 571 | 571 | <td data-toggle="collapse" data-target=".collapse[+id+]"><a class="[+status+]" title="[%edit_resource%]" href="index.php?a=3&id=[+id+]" target="main">[+pagetitle+]</a></td> |
@@ -589,16 +589,16 @@ discard block |
||
| 589 | 589 | </div> |
| 590 | 590 | </td> |
| 591 | 591 | </tr>'; |
| 592 | - return $tpl; |
|
| 592 | + return $tpl; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // setup icons |
| 596 | 596 | function wrapIcon($i, $action) {
|
| 597 | - return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
|
|
| 597 | + return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
|
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | function getStartUpScript() {
|
| 601 | - $script = ' |
|
| 601 | + $script = ' |
|
| 602 | 602 | <script type="text/javascript"> |
| 603 | 603 | function hideConfigCheckWarning(key) {
|
| 604 | 604 | var xhr = new XMLHttpRequest(); |
@@ -622,5 +622,5 @@ discard block |
||
| 622 | 622 | })(jQuery); |
| 623 | 623 | </script> |
| 624 | 624 | '; |
| 625 | - return $script; |
|
| 625 | + return $script; |
|
| 626 | 626 | } |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes |
| 7 | 7 | |
| 8 | -if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
|
|
| 8 | +if ($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
|
|
| 9 | 9 | // seems to be a new install - send the user to the configuration page |
| 10 | 10 | exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
|
| 11 | 11 | } |
@@ -16,50 +16,50 @@ discard block |
||
| 16 | 16 | $_SESSION['nrnewmessages'] = 0; |
| 17 | 17 | |
| 18 | 18 | // setup message info |
| 19 | -if($modx->hasPermission('messages')) {
|
|
| 20 | - include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
|
| 19 | +if ($modx->hasPermission('messages')) {
|
|
| 20 | + include_once(MODX_MANAGER_PATH.'includes/messageCount.inc.php'); |
|
| 21 | 21 | $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
| 22 | 22 | $_SESSION['nrnewmessages'] = $nrnewmessages; |
| 23 | 23 | |
| 24 | 24 | $msg = array(); |
| 25 | 25 | $msg[] = sprintf('<a href="index.php?a=10" target="main"><img src="%s" /></a>', $_style['icons_mail_large']);
|
| 26 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">' . $_SESSION['nrnewmessages'] . '</span>)' : ''; |
|
| 26 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (<span style="color:red">'.$_SESSION['nrnewmessages'].'</span>)' : ''; |
|
| 27 | 27 | $msg[] = sprintf('<span style="color:#909090;font-size:15px;font-weight:bold"> <a class="wm_messages_inbox_link" href="index.php?a=10" target="main">[%%inbox%%]</a>%s</span><br />', $nrnewmessages);
|
| 28 | - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">' . $_SESSION['nrnewmessages'] . '</span>' : '0'; |
|
| 28 | + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '<span style="color:red;">'.$_SESSION['nrnewmessages'].'</span>' : '0'; |
|
| 29 | 29 | $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); |
| 30 | 30 | $msg[] = sprintf('<span class="comment">%s</span>', $welcome_messages);
|
| 31 | 31 | $ph['MessageInfo'] = implode("\n", $msg);
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // setup icons |
| 35 | -if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
|
|
| 35 | +if ($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
|
|
| 36 | 36 | $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
| 37 | 37 | $ph['SecurityIcon'] = wrapIcon($icon, 75); |
| 38 | 38 | } |
| 39 | -if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
|
|
| 39 | +if ($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
|
|
| 40 | 40 | $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
| 41 | 41 | $ph['WebUserIcon'] = wrapIcon($icon, 99); |
| 42 | 42 | } |
| 43 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
|
|
| 43 | +if ($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
|
|
| 44 | 44 | $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
| 45 | 45 | $ph['ModulesIcon'] = wrapIcon($icon, 106); |
| 46 | 46 | } |
| 47 | -if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
|
|
| 47 | +if ($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
|
|
| 48 | 48 | $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
| 49 | 49 | $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
| 50 | 50 | } |
| 51 | -if($modx->hasPermission('bk_manager')) {
|
|
| 51 | +if ($modx->hasPermission('bk_manager')) {
|
|
| 52 | 52 | $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
| 53 | 53 | $ph['BackupIcon'] = wrapIcon($icon, 93); |
| 54 | 54 | } |
| 55 | -if($modx->hasPermission('help')) {
|
|
| 55 | +if ($modx->hasPermission('help')) {
|
|
| 56 | 56 | $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
| 57 | 57 | $ph['HelpIcon'] = wrapIcon($icon, 9); |
| 58 | 58 | } |
| 59 | 59 | // do some config checks |
| 60 | -if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
|
|
| 61 | - include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
|
| 62 | - if($config_check_results != $_lang['configcheck_ok']) {
|
|
| 60 | +if (($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
|
|
| 61 | + include_once(MODX_MANAGER_PATH.'includes/config_check.inc.php'); |
|
| 62 | + if ($config_check_results != $_lang['configcheck_ok']) {
|
|
| 63 | 63 | $ph['config_check_results'] = $config_check_results; |
| 64 | 64 | $ph['config_display'] = 'block'; |
| 65 | 65 | } else {
|
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check logout-reminder |
| 73 | -if(isset($_SESSION['show_logout_reminder'])) {
|
|
| 74 | - switch($_SESSION['show_logout_reminder']['type']) {
|
|
| 73 | +if (isset($_SESSION['show_logout_reminder'])) {
|
|
| 74 | + switch ($_SESSION['show_logout_reminder']['type']) {
|
|
| 75 | 75 | case 'logout_reminder': |
| 76 | 76 | $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
| 77 | 77 | $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
|
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | </tr> |
| 126 | 126 | </table>'; |
| 127 | 127 | |
| 128 | -$nrnewmessages = '<span class="text-danger">' . $_SESSION['nrnewmessages'] . '</span>'; |
|
| 128 | +$nrnewmessages = '<span class="text-danger">'.$_SESSION['nrnewmessages'].'</span>'; |
|
| 129 | 129 | |
| 130 | 130 | $ph['UserInfo'] = $modx->parseText($tpl, array( |
| 131 | 131 | 'username' => $modx->getLoginUserName(), |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'"; |
| 141 | 141 | $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
|
| 142 | 142 | |
| 143 | -if($modx->db->getRecordCount($rs) < 1) {
|
|
| 143 | +if ($modx->db->getRecordCount($rs) < 1) {
|
|
| 144 | 144 | $html = '<p>[%no_active_users_found%]</p>'; |
| 145 | 145 | } else {
|
| 146 | - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
|
| 146 | + include_once(MODX_MANAGER_PATH.'includes/actionlist.inc.php'); |
|
| 147 | 147 | $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
| 148 | 148 | $ph['now'] = strftime('%H:%M:%S', $now);
|
| 149 | 149 | $timetocheck = ($now - (60 * 20)); //+$server_offset_time; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $userList = array(); |
| 169 | 169 | $userCount = array(); |
| 170 | 170 | // Create userlist with session-count first before output |
| 171 | - while($activeusers = $modx->db->getRow($rs)) {
|
|
| 171 | + while ($activeusers = $modx->db->getRow($rs)) {
|
|
| 172 | 172 | $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
| 173 | 173 | |
| 174 | 174 | $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | $currentaction |
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | - foreach($userList as $params) {
|
|
| 189 | + foreach ($userList as $params) {
|
|
| 190 | 190 | $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
| 191 | - $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
|
|
| 191 | + $html .= "\n\t\t".vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
|
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $html .= ' |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $ph['OnlineInfo'] = $html; |
| 201 | 201 | |
| 202 | 202 | // include rss feeds for important forum topics |
| 203 | -include_once(MODX_MANAGER_PATH . 'includes/rss.inc.php'); |
|
| 203 | +include_once(MODX_MANAGER_PATH.'includes/rss.inc.php'); |
|
| 204 | 204 | $ph['modx_security_notices_content'] = $feedData['modx_security_notices_content']; |
| 205 | 205 | $ph['modx_news_content'] = $feedData['modx_news_content']; |
| 206 | 206 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | // invoke event OnManagerWelcomePrerender |
| 233 | 233 | $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
|
| 234 | -if(is_array($evtOut)) {
|
|
| 234 | +if (is_array($evtOut)) {
|
|
| 235 | 235 | $output = implode('', $evtOut);
|
| 236 | 236 | $ph['OnManagerWelcomePrerender'] = $output; |
| 237 | 237 | } |
@@ -365,57 +365,57 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | // invoke OnManagerWelcomeHome event |
| 367 | 367 | $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
|
| 368 | -if(is_array($sitewidgets)) {
|
|
| 368 | +if (is_array($sitewidgets)) {
|
|
| 369 | 369 | $newwidgets = array(); |
| 370 | - foreach($sitewidgets as $widget){
|
|
| 370 | + foreach ($sitewidgets as $widget) {
|
|
| 371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); |
| 372 | 372 | } |
| 373 | 373 | $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | -usort($widgets, function ($a, $b) {
|
|
| 376 | +usort($widgets, function($a, $b){
|
|
| 377 | 377 | return $a['menuindex'] - $b['menuindex']; |
| 378 | 378 | }); |
| 379 | 379 | |
| 380 | 380 | $tpl = getTplWidget(); |
| 381 | 381 | $output = ''; |
| 382 | -foreach($widgets as $widget) {
|
|
| 383 | - if ($widget['hide'] != '1'){
|
|
| 382 | +foreach ($widgets as $widget) {
|
|
| 383 | + if ($widget['hide'] != '1') {
|
|
| 384 | 384 | $output .= $modx->parseText($tpl, $widget); |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | $ph['widgets'] = $output; |
| 388 | 388 | |
| 389 | 389 | // load template |
| 390 | -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
|
|
| 391 | - $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
|
| 390 | +if (!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
|
|
| 391 | + $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH.'media/style/common/welcome.tpl'; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $target = $modx->config['manager_welcome_tpl']; |
| 395 | 395 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
|
| 396 | 396 | $target = $modx->mergeSettingsContent($target); |
| 397 | 397 | |
| 398 | -if(substr($target, 0, 1) === '@') {
|
|
| 399 | - if(substr($target, 0, 6) === '@CHUNK') {
|
|
| 398 | +if (substr($target, 0, 1) === '@') {
|
|
| 399 | + if (substr($target, 0, 6) === '@CHUNK') {
|
|
| 400 | 400 | $content = $modx->getChunk(trim(substr($target, 7))); |
| 401 | - } elseif(substr($target, 0, 5) === '@FILE') {
|
|
| 401 | + } elseif (substr($target, 0, 5) === '@FILE') {
|
|
| 402 | 402 | $content = file_get_contents(trim(substr($target, 6))); |
| 403 | 403 | } else {
|
| 404 | 404 | $content = ''; |
| 405 | 405 | } |
| 406 | 406 | } else {
|
| 407 | 407 | $chunk = $modx->getChunk($target); |
| 408 | - if($chunk !== false && !empty($chunk)) {
|
|
| 408 | + if ($chunk !== false && !empty($chunk)) {
|
|
| 409 | 409 | $content = $chunk; |
| 410 | - } elseif(is_file(MODX_BASE_PATH . $target)) {
|
|
| 411 | - $content = file_get_contents(MODX_BASE_PATH . $target); |
|
| 412 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
|
|
| 413 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
|
| 414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
| 410 | + } elseif (is_file(MODX_BASE_PATH.$target)) {
|
|
| 411 | + $content = file_get_contents(MODX_BASE_PATH.$target); |
|
| 412 | + } elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl')) {
|
|
| 413 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/welcome.tpl'); |
|
| 414 | + } elseif (is_file(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html')) // ClipperCMS compatible |
|
| 415 | 415 | {
|
| 416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
| 416 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/html/welcome.html'); |
|
| 417 | 417 | } else {
|
| 418 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
|
| 418 | + $content = file_get_contents(MODX_MANAGER_PATH.'media/style/common/welcome.tpl'); |
|
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | $content = $modx->mergeConditionalTagsContent($content); |
| 424 | 424 | $content = $modx->mergeSettingsContent($content); |
| 425 | 425 | $content = $modx->parseText($content, $ph); |
| 426 | -if(strpos($content, '[+') !== false) {
|
|
| 426 | +if (strpos($content, '[+') !== false) {
|
|
| 427 | 427 | $modx->toPlaceholders($ph); |
| 428 | 428 | $content = $modx->mergePlaceholderContent($content); |
| 429 | 429 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $content = $modx->parseText($content, $_style, '[&', '&]'); |
| 433 | 433 | $content = $modx->cleanUpMODXTags($content); //cleanup |
| 434 | 434 | |
| 435 | -if($js = $modx->getRegisteredClientScripts()) {
|
|
| 435 | +if ($js = $modx->getRegisteredClientScripts()) {
|
|
| 436 | 436 | $content .= $js; |
| 437 | 437 | } |
| 438 | 438 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | // <a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a> |
| 443 | 443 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> |
| 444 | 444 | //</span> |
| 445 | -function getTplWidget() { // recent document info
|
|
| 445 | +function getTplWidget(){ // recent document info
|
|
| 446 | 446 | return ' |
| 447 | 447 | <div class="[+cols+]" id="[+id+]"> |
| 448 | 448 | <div class="card"[+cardAttr+]> |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | '; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | -function getRecentInfo() { // recent document info
|
|
| 456 | +function getRecentInfo(){ // recent document info
|
|
| 457 | 457 | global $modx; |
| 458 | 458 | |
| 459 | 459 | $modx->addSnippet('recentInfoList', 'getRecentInfoList');
|
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | return $html; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | -function getRecentInfoList() {
|
|
| 482 | +function getRecentInfoList(){
|
|
| 483 | 483 | global $modx; |
| 484 | 484 | |
| 485 | 485 | $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
|
| 486 | 486 | |
| 487 | - if($modx->db->getRecordCount($rs) < 1) {
|
|
| 487 | + if ($modx->db->getRecordCount($rs) < 1) {
|
|
| 488 | 488 | return '<tr><td>[%no_activity_message%]</td></tr>'; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -494,20 +494,20 @@ discard block |
||
| 494 | 494 | $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
| 495 | 495 | |
| 496 | 496 | $output = array(); |
| 497 | - while($ph = $modx->db->getRow($rs)) {
|
|
| 497 | + while ($ph = $modx->db->getRow($rs)) {
|
|
| 498 | 498 | $docid = $ph['id']; |
| 499 | 499 | $_ = $modx->getUserInfo($ph['editedby']); |
| 500 | 500 | $ph['username'] = $_['username']; |
| 501 | 501 | |
| 502 | - if($ph['deleted'] == 1) {
|
|
| 502 | + if ($ph['deleted'] == 1) {
|
|
| 503 | 503 | $ph['status'] = 'deleted text-danger'; |
| 504 | - } elseif($ph['published'] == 0) {
|
|
| 504 | + } elseif ($ph['published'] == 0) {
|
|
| 505 | 505 | $ph['status'] = 'unpublished font-italic text-muted'; |
| 506 | 506 | } else {
|
| 507 | 507 | $ph['status'] = 'published'; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if($modx->hasPermission('edit_document')) {
|
|
| 510 | + if ($modx->hasPermission('edit_document')) {
|
|
| 511 | 511 | $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
|
| 512 | 512 | } else {
|
| 513 | 513 | $ph['edit_btn'] = ''; |
@@ -522,8 +522,8 @@ discard block |
||
| 522 | 522 | $preview_disabled |
| 523 | 523 | ), $btntpl['preview_btn']); |
| 524 | 524 | |
| 525 | - if($modx->hasPermission('delete_document')) {
|
|
| 526 | - if($ph['deleted'] == 0) {
|
|
| 525 | + if ($modx->hasPermission('delete_document')) {
|
|
| 526 | + if ($ph['deleted'] == 0) {
|
|
| 527 | 527 | $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
| 528 | 528 | } else {
|
| 529 | 529 | $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
@@ -533,11 +533,11 @@ discard block |
||
| 533 | 533 | $ph['delete_btn'] = ''; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - if($ph['deleted'] == 1 && $ph['published'] == 0) {
|
|
| 536 | + if ($ph['deleted'] == 1 && $ph['published'] == 0) {
|
|
| 537 | 537 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
| 538 | - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
|
|
| 538 | + } elseif ($ph['deleted'] == 1 && $ph['published'] == 1) {
|
|
| 539 | 539 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
| 540 | - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
|
|
| 540 | + } elseif ($ph['deleted'] == 0 && $ph['published'] == 0) {
|
|
| 541 | 541 | $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
| 542 | 542 | } else {
|
| 543 | 543 | $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
@@ -546,16 +546,16 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
|
| 548 | 548 | |
| 549 | - if($ph['longtitle'] == '') {
|
|
| 549 | + if ($ph['longtitle'] == '') {
|
|
| 550 | 550 | $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
| 551 | 551 | } |
| 552 | - if($ph['description'] == '') {
|
|
| 552 | + if ($ph['description'] == '') {
|
|
| 553 | 553 | $ph['description'] = '(<i>[%not_set%]</i>)'; |
| 554 | 554 | } |
| 555 | - if($ph['introtext'] == '') {
|
|
| 555 | + if ($ph['introtext'] == '') {
|
|
| 556 | 556 | $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
| 557 | 557 | } |
| 558 | - if($ph['alias'] == '') {
|
|
| 558 | + if ($ph['alias'] == '') {
|
|
| 559 | 559 | $ph['alias'] = '(<i>[%not_set%]</i>)'; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | return implode("\n", $output);
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | -function getRecentInfoRowTpl() {
|
|
| 567 | +function getRecentInfoRowTpl(){
|
|
| 568 | 568 | $tpl = ' |
| 569 | 569 | <tr> |
| 570 | 570 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // setup icons |
| 596 | -function wrapIcon($i, $action) {
|
|
| 596 | +function wrapIcon($i, $action){
|
|
| 597 | 597 | return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | -function getStartUpScript() {
|
|
| 600 | +function getStartUpScript(){
|
|
| 601 | 601 | $script = ' |
| 602 | 602 | <script type="text/javascript"> |
| 603 | 603 | function hideConfigCheckWarning(key) {
|
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes |
| 7 | 7 | |
| 8 | -if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) {
|
|
| 8 | +if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { |
|
| 9 | 9 | // seems to be a new install - send the user to the configuration page |
| 10 | 10 | exit('<script type="text/javascript">document.location.href="index.php?a=17";</script>');
|
| 11 | 11 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $_SESSION['nrnewmessages'] = 0; |
| 17 | 17 | |
| 18 | 18 | // setup message info |
| 19 | -if($modx->hasPermission('messages')) {
|
|
| 19 | +if($modx->hasPermission('messages')) { |
|
| 20 | 20 | include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); |
| 21 | 21 | $_SESSION['nrtotalmessages'] = $nrtotalmessages; |
| 22 | 22 | $_SESSION['nrnewmessages'] = $nrnewmessages; |
@@ -32,46 +32,46 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // setup icons |
| 35 | -if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) {
|
|
| 35 | +if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { |
|
| 36 | 36 | $icon = '<i class="[&icons_security_large&]" alt="[%user_management_title%]"> </i>[%user_management_title%]'; |
| 37 | 37 | $ph['SecurityIcon'] = wrapIcon($icon, 75); |
| 38 | 38 | } |
| 39 | -if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) {
|
|
| 39 | +if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { |
|
| 40 | 40 | $icon = '<i class="[&icons_webusers_large&]" alt="[%web_user_management_title%]"> </i>[%web_user_management_title%]'; |
| 41 | 41 | $ph['WebUserIcon'] = wrapIcon($icon, 99); |
| 42 | 42 | } |
| 43 | -if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
|
|
| 43 | +if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { |
|
| 44 | 44 | $icon = '<i class="[&icons_modules_large&]" alt="[%manage_modules%]"> </i>[%modules%]'; |
| 45 | 45 | $ph['ModulesIcon'] = wrapIcon($icon, 106); |
| 46 | 46 | } |
| 47 | -if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) {
|
|
| 47 | +if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { |
|
| 48 | 48 | $icon = '<i class="[&icons_resources_large&]" alt="[%element_management%]"> </i>[%elements%]'; |
| 49 | 49 | $ph['ResourcesIcon'] = wrapIcon($icon, 76); |
| 50 | 50 | } |
| 51 | -if($modx->hasPermission('bk_manager')) {
|
|
| 51 | +if($modx->hasPermission('bk_manager')) { |
|
| 52 | 52 | $icon = '<i class="[&icons_backup_large&]" alt="[%bk_manager%]"> </i>[%backup%]'; |
| 53 | 53 | $ph['BackupIcon'] = wrapIcon($icon, 93); |
| 54 | 54 | } |
| 55 | -if($modx->hasPermission('help')) {
|
|
| 55 | +if($modx->hasPermission('help')) { |
|
| 56 | 56 | $icon = '<i class="[&icons_help_large&]" alt="[%help%]" /> </i>[%help%]'; |
| 57 | 57 | $ph['HelpIcon'] = wrapIcon($icon, 9); |
| 58 | 58 | } |
| 59 | 59 | // do some config checks |
| 60 | -if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) {
|
|
| 60 | +if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { |
|
| 61 | 61 | include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); |
| 62 | - if($config_check_results != $_lang['configcheck_ok']) {
|
|
| 62 | + if($config_check_results != $_lang['configcheck_ok']) { |
|
| 63 | 63 | $ph['config_check_results'] = $config_check_results; |
| 64 | 64 | $ph['config_display'] = 'block'; |
| 65 | - } else {
|
|
| 65 | + } else { |
|
| 66 | 66 | $ph['config_display'] = 'none'; |
| 67 | 67 | } |
| 68 | -} else {
|
|
| 68 | +} else { |
|
| 69 | 69 | $ph['config_display'] = 'none'; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check logout-reminder |
| 73 | -if(isset($_SESSION['show_logout_reminder'])) {
|
|
| 74 | - switch($_SESSION['show_logout_reminder']['type']) {
|
|
| 73 | +if(isset($_SESSION['show_logout_reminder'])) { |
|
| 74 | + switch($_SESSION['show_logout_reminder']['type']) { |
|
| 75 | 75 | case 'logout_reminder': |
| 76 | 76 | $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); |
| 77 | 77 | $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']);
|
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | $ph['show_logout_reminder'] = 'block'; |
| 81 | 81 | unset($_SESSION['show_logout_reminder']); |
| 82 | -} else {
|
|
| 82 | +} else { |
|
| 83 | 83 | $ph['show_logout_reminder'] = 'none'; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | $from[] = " us LEFT JOIN [+prefix+]active_users au ON au.sid=us.sid WHERE au.action <> '8'"; |
| 141 | 141 | $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC');
|
| 142 | 142 | |
| 143 | -if($modx->db->getRecordCount($rs) < 1) {
|
|
| 143 | +if($modx->db->getRecordCount($rs) < 1) { |
|
| 144 | 144 | $html = '<p>[%no_active_users_found%]</p>'; |
| 145 | -} else {
|
|
| 145 | +} else { |
|
| 146 | 146 | include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); |
| 147 | 147 | $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; |
| 148 | 148 | $ph['now'] = strftime('%H:%M:%S', $now);
|
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $userList = array(); |
| 169 | 169 | $userCount = array(); |
| 170 | 170 | // Create userlist with session-count first before output |
| 171 | - while($activeusers = $modx->db->getRow($rs)) {
|
|
| 171 | + while($activeusers = $modx->db->getRow($rs)) { |
|
| 172 | 172 | $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; |
| 173 | 173 | |
| 174 | 174 | $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $currentaction |
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | - foreach($userList as $params) {
|
|
| 189 | + foreach($userList as $params) { |
|
| 190 | 190 | $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; |
| 191 | 191 | $html .= "\n\t\t" . vsprintf('<tr%s><td><strong%s>%s</strong></td><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $params);
|
| 192 | 192 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | // invoke event OnManagerWelcomePrerender |
| 233 | 233 | $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender');
|
| 234 | -if(is_array($evtOut)) {
|
|
| 234 | +if(is_array($evtOut)) { |
|
| 235 | 235 | $output = implode('', $evtOut);
|
| 236 | 236 | $ph['OnManagerWelcomePrerender'] = $output; |
| 237 | 237 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | 'body' => '<div class="widget-stage">[+RecentInfo+]</div>', |
| 341 | 341 | 'hide'=>'0' |
| 342 | 342 | ); |
| 343 | -if ($modx->config['rss_url_news']) {
|
|
| 343 | +if ($modx->config['rss_url_news']) { |
|
| 344 | 344 | $widgets['news'] = array( |
| 345 | 345 | 'menuindex' => '40', |
| 346 | 346 | 'id' => 'news', |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | 'hide'=>'0' |
| 352 | 352 | ); |
| 353 | 353 | } |
| 354 | -if ($modx->config['rss_url_security']) {
|
|
| 354 | +if ($modx->config['rss_url_security']) { |
|
| 355 | 355 | $widgets['security'] = array( |
| 356 | 356 | 'menuindex' => '50', |
| 357 | 357 | 'id' => 'security', |
@@ -365,29 +365,29 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | // invoke OnManagerWelcomeHome event |
| 367 | 367 | $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets));
|
| 368 | -if(is_array($sitewidgets)) {
|
|
| 368 | +if(is_array($sitewidgets)) { |
|
| 369 | 369 | $newwidgets = array(); |
| 370 | - foreach($sitewidgets as $widget){
|
|
| 370 | + foreach($sitewidgets as $widget) { |
|
| 371 | 371 | $newwidgets = array_merge($newwidgets, unserialize($widget)); |
| 372 | 372 | } |
| 373 | 373 | $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | -usort($widgets, function ($a, $b) {
|
|
| 376 | +usort($widgets, function ($a, $b){ |
|
| 377 | 377 | return $a['menuindex'] - $b['menuindex']; |
| 378 | 378 | }); |
| 379 | 379 | |
| 380 | 380 | $tpl = getTplWidget(); |
| 381 | 381 | $output = ''; |
| 382 | -foreach($widgets as $widget) {
|
|
| 383 | - if ($widget['hide'] != '1'){
|
|
| 382 | +foreach($widgets as $widget) { |
|
| 383 | + if ($widget['hide'] != '1') { |
|
| 384 | 384 | $output .= $modx->parseText($tpl, $widget); |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | $ph['widgets'] = $output; |
| 388 | 388 | |
| 389 | 389 | // load template |
| 390 | -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) {
|
|
| 390 | +if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { |
|
| 391 | 391 | $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -395,26 +395,28 @@ discard block |
||
| 395 | 395 | $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target);
|
| 396 | 396 | $target = $modx->mergeSettingsContent($target); |
| 397 | 397 | |
| 398 | -if(substr($target, 0, 1) === '@') {
|
|
| 399 | - if(substr($target, 0, 6) === '@CHUNK') {
|
|
| 398 | +if(substr($target, 0, 1) === '@') { |
|
| 399 | + if(substr($target, 0, 6) === '@CHUNK') { |
|
| 400 | 400 | $content = $modx->getChunk(trim(substr($target, 7))); |
| 401 | - } elseif(substr($target, 0, 5) === '@FILE') {
|
|
| 401 | + } elseif(substr($target, 0, 5) === '@FILE') { |
|
| 402 | 402 | $content = file_get_contents(trim(substr($target, 6))); |
| 403 | - } else {
|
|
| 403 | + } else { |
|
| 404 | 404 | $content = ''; |
| 405 | 405 | } |
| 406 | -} else {
|
|
| 406 | +} else { |
|
| 407 | 407 | $chunk = $modx->getChunk($target); |
| 408 | - if($chunk !== false && !empty($chunk)) {
|
|
| 408 | + if($chunk !== false && !empty($chunk)) { |
|
| 409 | 409 | $content = $chunk; |
| 410 | - } elseif(is_file(MODX_BASE_PATH . $target)) {
|
|
| 410 | + } elseif(is_file(MODX_BASE_PATH . $target)) { |
|
| 411 | 411 | $content = file_get_contents(MODX_BASE_PATH . $target); |
| 412 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) {
|
|
| 412 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { |
|
| 413 | 413 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); |
| 414 | - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible |
|
| 414 | + } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) { |
|
| 415 | + // ClipperCMS compatible |
|
| 415 | 416 | {
|
| 416 | - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
| 417 | - } else {
|
|
| 417 | + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); |
|
| 418 | + } |
|
| 419 | + } else { |
|
| 418 | 420 | $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); |
| 419 | 421 | } |
| 420 | 422 | } |
@@ -423,7 +425,7 @@ discard block |
||
| 423 | 425 | $content = $modx->mergeConditionalTagsContent($content); |
| 424 | 426 | $content = $modx->mergeSettingsContent($content); |
| 425 | 427 | $content = $modx->parseText($content, $ph); |
| 426 | -if(strpos($content, '[+') !== false) {
|
|
| 428 | +if(strpos($content, '[+') !== false) { |
|
| 427 | 429 | $modx->toPlaceholders($ph); |
| 428 | 430 | $content = $modx->mergePlaceholderContent($content); |
| 429 | 431 | } |
@@ -432,7 +434,7 @@ discard block |
||
| 432 | 434 | $content = $modx->parseText($content, $_style, '[&', '&]'); |
| 433 | 435 | $content = $modx->cleanUpMODXTags($content); //cleanup |
| 434 | 436 | |
| 435 | -if($js = $modx->getRegisteredClientScripts()) {
|
|
| 437 | +if($js = $modx->getRegisteredClientScripts()) { |
|
| 436 | 438 | $content .= $js; |
| 437 | 439 | } |
| 438 | 440 | |
@@ -442,7 +444,9 @@ discard block |
||
| 442 | 444 | // <a href="javascript:;" class="setting"><i class="fa fa-cog"></i></a> |
| 443 | 445 | // <a href="javascript:;" class="closed"><i class="fa fa-close"></i></a> |
| 444 | 446 | //</span> |
| 445 | -function getTplWidget() { // recent document info
|
|
| 447 | +function getTplWidget() |
|
| 448 | +{ |
|
| 449 | +// recent document info |
|
| 446 | 450 | return ' |
| 447 | 451 | <div class="[+cols+]" id="[+id+]"> |
| 448 | 452 | <div class="card"[+cardAttr+]> |
@@ -453,7 +457,9 @@ discard block |
||
| 453 | 457 | '; |
| 454 | 458 | } |
| 455 | 459 | |
| 456 | -function getRecentInfo() { // recent document info
|
|
| 460 | +function getRecentInfo() |
|
| 461 | +{ |
|
| 462 | +// recent document info |
|
| 457 | 463 | global $modx; |
| 458 | 464 | |
| 459 | 465 | $modx->addSnippet('recentInfoList', 'getRecentInfoList');
|
@@ -479,12 +485,13 @@ discard block |
||
| 479 | 485 | return $html; |
| 480 | 486 | } |
| 481 | 487 | |
| 482 | -function getRecentInfoList() {
|
|
| 488 | +function getRecentInfoList() |
|
| 489 | +{ |
|
| 483 | 490 | global $modx; |
| 484 | 491 | |
| 485 | 492 | $rs = $modx->db->select('*', '[+prefix+]site_content', '', 'editedon DESC', 10);
|
| 486 | 493 | |
| 487 | - if($modx->db->getRecordCount($rs) < 1) {
|
|
| 494 | + if($modx->db->getRecordCount($rs) < 1) { |
|
| 488 | 495 | return '<tr><td>[%no_activity_message%]</td></tr>'; |
| 489 | 496 | } |
| 490 | 497 | |
@@ -494,22 +501,22 @@ discard block |
||
| 494 | 501 | $btntpl['preview_btn'] = '<a [+preview_disabled+]" title="[%preview_resource%]" target="_blank" href="../index.php?&id=[+id+]"><i class="fa fa-eye fa-fw"></i></a> '; |
| 495 | 502 | |
| 496 | 503 | $output = array(); |
| 497 | - while($ph = $modx->db->getRow($rs)) {
|
|
| 504 | + while($ph = $modx->db->getRow($rs)) { |
|
| 498 | 505 | $docid = $ph['id']; |
| 499 | 506 | $_ = $modx->getUserInfo($ph['editedby']); |
| 500 | 507 | $ph['username'] = $_['username']; |
| 501 | 508 | |
| 502 | - if($ph['deleted'] == 1) {
|
|
| 509 | + if($ph['deleted'] == 1) { |
|
| 503 | 510 | $ph['status'] = 'deleted text-danger'; |
| 504 | - } elseif($ph['published'] == 0) {
|
|
| 511 | + } elseif($ph['published'] == 0) { |
|
| 505 | 512 | $ph['status'] = 'unpublished font-italic text-muted'; |
| 506 | - } else {
|
|
| 513 | + } else { |
|
| 507 | 514 | $ph['status'] = 'published'; |
| 508 | 515 | } |
| 509 | 516 | |
| 510 | - if($modx->hasPermission('edit_document')) {
|
|
| 517 | + if($modx->hasPermission('edit_document')) { |
|
| 511 | 518 | $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']);
|
| 512 | - } else {
|
|
| 519 | + } else { |
|
| 513 | 520 | $ph['edit_btn'] = ''; |
| 514 | 521 | } |
| 515 | 522 | |
@@ -522,40 +529,40 @@ discard block |
||
| 522 | 529 | $preview_disabled |
| 523 | 530 | ), $btntpl['preview_btn']); |
| 524 | 531 | |
| 525 | - if($modx->hasPermission('delete_document')) {
|
|
| 526 | - if($ph['deleted'] == 0) {
|
|
| 532 | + if($modx->hasPermission('delete_document')) { |
|
| 533 | + if($ph['deleted'] == 0) { |
|
| 527 | 534 | $delete_btn = '<a onclick="return confirm(\'[%confirm_delete_record%]\')" title="[%delete_resource%]" href="index.php?a=6&id=[+id+]" target="main"><i class="fa fa-trash fa-fw"></i></a> '; |
| 528 | - } else {
|
|
| 535 | + } else { |
|
| 529 | 536 | $delete_btn = '<a onclick="return confirm(\'[%confirm_undelete%]\')" title="[%undelete_resource%]" href="index.php?a=63&id=[+id+]" target="main"><i class="fa fa-arrow-circle-o-up fa-fw"></i></a> '; |
| 530 | 537 | } |
| 531 | 538 | $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn);
|
| 532 | - } else {
|
|
| 539 | + } else { |
|
| 533 | 540 | $ph['delete_btn'] = ''; |
| 534 | 541 | } |
| 535 | 542 | |
| 536 | - if($ph['deleted'] == 1 && $ph['published'] == 0) {
|
|
| 543 | + if($ph['deleted'] == 1 && $ph['published'] == 0) { |
|
| 537 | 544 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
| 538 | - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) {
|
|
| 545 | + } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { |
|
| 539 | 546 | $publish_btn = '<a class="disabled" title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
| 540 | - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) {
|
|
| 547 | + } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { |
|
| 541 | 548 | $publish_btn = '<a title="[%publish_resource%]" href="index.php?a=61&id=[+id+]" target="main"><i class="fa fa-arrow-up fa-fw"></i></a> '; |
| 542 | - } else {
|
|
| 549 | + } else { |
|
| 543 | 550 | $publish_btn = '<a title="[%unpublish_resource%]" href="index.php?a=62&id=[+id+]" target="main"><i class="fa fa-arrow-down fa-fw"></i></a> '; |
| 544 | 551 | } |
| 545 | 552 | $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn);
|
| 546 | 553 | |
| 547 | 554 | $ph['info_btn'] = str_replace('[+id+]', $docid, '<a title="[%resource_overview%]" data-toggle="collapse" data-target=".collapse[+id+]"><i class="fa fa-info fa-fw"></i></a>');
|
| 548 | 555 | |
| 549 | - if($ph['longtitle'] == '') {
|
|
| 556 | + if($ph['longtitle'] == '') { |
|
| 550 | 557 | $ph['longtitle'] = '(<i>[%not_set%]</i>)'; |
| 551 | 558 | } |
| 552 | - if($ph['description'] == '') {
|
|
| 559 | + if($ph['description'] == '') { |
|
| 553 | 560 | $ph['description'] = '(<i>[%not_set%]</i>)'; |
| 554 | 561 | } |
| 555 | - if($ph['introtext'] == '') {
|
|
| 562 | + if($ph['introtext'] == '') { |
|
| 556 | 563 | $ph['introtext'] = '(<i>[%not_set%]</i>)'; |
| 557 | 564 | } |
| 558 | - if($ph['alias'] == '') {
|
|
| 565 | + if($ph['alias'] == '') { |
|
| 559 | 566 | $ph['alias'] = '(<i>[%not_set%]</i>)'; |
| 560 | 567 | } |
| 561 | 568 | |
@@ -564,7 +571,8 @@ discard block |
||
| 564 | 571 | return implode("\n", $output);
|
| 565 | 572 | } |
| 566 | 573 | |
| 567 | -function getRecentInfoRowTpl() {
|
|
| 574 | +function getRecentInfoRowTpl() |
|
| 575 | +{ |
|
| 568 | 576 | $tpl = ' |
| 569 | 577 | <tr> |
| 570 | 578 | <td data-toggle="collapse" data-target=".collapse[+id+]" class="text-right"><span class="label label-info">[+id+]</span></td> |
@@ -593,11 +601,13 @@ discard block |
||
| 593 | 601 | } |
| 594 | 602 | |
| 595 | 603 | // setup icons |
| 596 | -function wrapIcon($i, $action) {
|
|
| 604 | +function wrapIcon($i, $action) |
|
| 605 | +{ |
|
| 597 | 606 | return sprintf('<a href="index.php?a=%s" target="main"><span class="wm_button" style="border:0">%s</span></a>', $action, $i);
|
| 598 | 607 | } |
| 599 | 608 | |
| 600 | -function getStartUpScript() {
|
|
| 609 | +function getStartUpScript() |
|
| 610 | +{ |
|
| 601 | 611 | $script = ' |
| 602 | 612 | <script type="text/javascript"> |
| 603 | 613 | function hideConfigCheckWarning(key) {
|
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | $modx->getSettings(); |
| 6 | 6 | $modx->invokeEvent('OnWebPageInit'); |
| 7 | 7 | |
| 8 | -$vword = new VeriWord(148,60); |
|
| 8 | +$vword = new VeriWord(148, 60); |
|
| 9 | 9 | $vword->output_image(); |
| 10 | 10 | $vword->destroy_image(); |
| 11 | 11 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord{ |
|
| 45 | 45 | |
| 46 | 46 | /* path to font directory*/ |
| 47 | 47 | public $dir_font = "ttf/"; |
@@ -52,44 +52,44 @@ discard block |
||
| 52 | 52 | public $im_height = 0; |
| 53 | 53 | public $im; |
| 54 | 54 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 55 | + public function __construct($w = 200, $h = 80){ |
|
| 56 | 56 | /* create session to set word for verification */ |
| 57 | 57 | $this->set_veriword(); |
| 58 | - $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
|
| 58 | + $this->dir_font = dirname(__FILE__).'/'.$this->dir_font; |
|
| 59 | 59 | $this->im_width = $w; |
| 60 | 60 | $this->im_height = $h; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function set_veriword() { |
|
| 63 | + public function set_veriword(){ |
|
| 64 | 64 | /* create session variable for verification, |
| 65 | 65 | you may change the session variable name */ |
| 66 | 66 | $this->word = $this->pick_word(); |
| 67 | 67 | $_SESSION['veriword'] = $this->word; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function output_image() { |
|
| 70 | + public function output_image(){ |
|
| 71 | 71 | /* output the image as jpeg */ |
| 72 | 72 | $this->draw_image(); |
| 73 | 73 | header("Content-type: image/jpeg"); |
| 74 | 74 | imagejpeg($this->im); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function pick_word() { |
|
| 77 | + public function pick_word(){ |
|
| 78 | 78 | global $modx; |
| 79 | 79 | // set default words |
| 80 | - $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 80 | + $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
| 81 | 81 | $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words; |
| 82 | 82 | $arr_words = array_filter(array_map('trim', explode(',', $words))); |
| 83 | 83 | |
| 84 | 84 | /* pick one randomly for text verification */ |
| 85 | - return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
|
| 85 | + return (string) $arr_words[array_rand($arr_words)].rand(10, 999); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function draw_text() { |
|
| 88 | + public function draw_text(){ |
|
| 89 | 89 | $dir = dir($this->dir_font); |
| 90 | 90 | $fontstmp = array(); |
| 91 | 91 | while (false !== ($file = $dir->read())) { |
| 92 | - if(substr($file, -4) == '.ttf') { |
|
| 92 | + if (substr($file, -4) == '.ttf') { |
|
| 93 | 93 | $fontstmp[] = $this->dir_font.$file; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -97,35 +97,35 @@ discard block |
||
| 97 | 97 | $text_font = (string) $fontstmp[array_rand($fontstmp)]; |
| 98 | 98 | |
| 99 | 99 | /* angle for text inclination */ |
| 100 | - $text_angle = rand(-9,9); |
|
| 100 | + $text_angle = rand(-9, 9); |
|
| 101 | 101 | /* initial text size */ |
| 102 | 102 | $text_size = 30; |
| 103 | 103 | /* calculate text width and height */ |
| 104 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 105 | - $text_width = $box[2]-$box[0]; //text width |
|
| 106 | - $text_height= $box[5]-$box[3]; //text height |
|
| 104 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 105 | + $text_width = $box[2] - $box[0]; //text width |
|
| 106 | + $text_height = $box[5] - $box[3]; //text height |
|
| 107 | 107 | |
| 108 | 108 | /* adjust text size */ |
| 109 | - $text_size = round((20 * $this->im_width)/$text_width); |
|
| 109 | + $text_size = round((20 * $this->im_width) / $text_width); |
|
| 110 | 110 | |
| 111 | 111 | /* recalculate text width and height */ |
| 112 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
| 113 | - $text_width = $box[2]-$box[0]; //text width |
|
| 114 | - $text_height= $box[5]-$box[3]; //text height |
|
| 112 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
| 113 | + $text_width = $box[2] - $box[0]; //text width |
|
| 114 | + $text_height = $box[5] - $box[3]; //text height |
|
| 115 | 115 | |
| 116 | 116 | /* calculate center position of text */ |
| 117 | - $text_x = ($this->im_width - $text_width)/2; |
|
| 118 | - $text_y = ($this->im_height - $text_height)/2; |
|
| 117 | + $text_x = ($this->im_width - $text_width) / 2; |
|
| 118 | + $text_y = ($this->im_height - $text_height) / 2; |
|
| 119 | 119 | |
| 120 | 120 | /* create canvas for text drawing */ |
| 121 | - $im_text = imagecreate ($this->im_width, $this->im_height); |
|
| 122 | - $bg_color = imagecolorallocate ($im_text, 255, 255, 255); |
|
| 121 | + $im_text = imagecreate($this->im_width, $this->im_height); |
|
| 122 | + $bg_color = imagecolorallocate($im_text, 255, 255, 255); |
|
| 123 | 123 | |
| 124 | 124 | /* pick color for text */ |
| 125 | - $text_color = imagecolorallocate ($im_text, 0, 51, 153); |
|
| 125 | + $text_color = imagecolorallocate($im_text, 0, 51, 153); |
|
| 126 | 126 | |
| 127 | 127 | /* draw text into canvas */ |
| 128 | - imagettftext ( $im_text, |
|
| 128 | + imagettftext($im_text, |
|
| 129 | 129 | $text_size, |
| 130 | 130 | $text_angle, |
| 131 | 131 | $text_x, |
@@ -140,19 +140,19 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - public function draw_image() { |
|
| 143 | + public function draw_image(){ |
|
| 144 | 144 | |
| 145 | 145 | /* pick one background image randomly from image directory */ |
| 146 | - $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
|
| 146 | + $img_file = $this->dir_noise."noise".rand(1, 4).".jpg"; |
|
| 147 | 147 | |
| 148 | 148 | /* create "noise" background image from your image stock*/ |
| 149 | - $noise_img = @imagecreatefromjpeg ($img_file); |
|
| 149 | + $noise_img = @imagecreatefromjpeg($img_file); |
|
| 150 | 150 | $noise_width = imagesx($noise_img); |
| 151 | 151 | $noise_height = imagesy($noise_img); |
| 152 | 152 | |
| 153 | 153 | /* resize the background image to fit the size of image output */ |
| 154 | - $this->im = imagecreatetruecolor($this->im_width,$this->im_height); |
|
| 155 | - imagecopyresampled ($this->im, |
|
| 154 | + $this->im = imagecreatetruecolor($this->im_width, $this->im_height); |
|
| 155 | + imagecopyresampled($this->im, |
|
| 156 | 156 | $noise_img, |
| 157 | 157 | 0, 0, 0, 0, |
| 158 | 158 | $this->im_width, |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | $noise_height); |
| 162 | 162 | |
| 163 | 163 | /* put text image into background image */ |
| 164 | - imagecopymerge ( $this->im, |
|
| 164 | + imagecopymerge($this->im, |
|
| 165 | 165 | $this->draw_text(), |
| 166 | 166 | 0, 0, 0, 0, |
| 167 | 167 | $this->im_width, |
| 168 | 168 | $this->im_height, |
| 169 | - 70 ); |
|
| 169 | + 70); |
|
| 170 | 170 | |
| 171 | 171 | return $this->im; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function destroy_image() { |
|
| 174 | + public function destroy_image(){ |
|
| 175 | 175 | |
| 176 | 176 | imagedestroy($this->im); |
| 177 | 177 | |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | ## see sample.php for test and usage |
| 42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
| 43 | 43 | #### |
| 44 | -class VeriWord { |
|
| 44 | +class VeriWord |
|
| 45 | +{ |
|
| 45 | 46 | |
| 46 | 47 | /* path to font directory*/ |
| 47 | 48 | public $dir_font = "ttf/"; |
@@ -52,7 +53,8 @@ discard block |
||
| 52 | 53 | public $im_height = 0; |
| 53 | 54 | public $im; |
| 54 | 55 | |
| 55 | - public function __construct($w=200, $h=80) { |
|
| 56 | + public function __construct($w=200, $h=80) |
|
| 57 | + { |
|
| 56 | 58 | /* create session to set word for verification */ |
| 57 | 59 | $this->set_veriword(); |
| 58 | 60 | $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
@@ -60,21 +62,24 @@ discard block |
||
| 60 | 62 | $this->im_height = $h; |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | - public function set_veriword() { |
|
| 65 | + public function set_veriword() |
|
| 66 | + { |
|
| 64 | 67 | /* create session variable for verification, |
| 65 | 68 | you may change the session variable name */ |
| 66 | 69 | $this->word = $this->pick_word(); |
| 67 | 70 | $_SESSION['veriword'] = $this->word; |
| 68 | 71 | } |
| 69 | 72 | |
| 70 | - public function output_image() { |
|
| 73 | + public function output_image() |
|
| 74 | + { |
|
| 71 | 75 | /* output the image as jpeg */ |
| 72 | 76 | $this->draw_image(); |
| 73 | 77 | header("Content-type: image/jpeg"); |
| 74 | 78 | imagejpeg($this->im); |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | - public function pick_word() { |
|
| 81 | + public function pick_word() |
|
| 82 | + { |
|
| 78 | 83 | global $modx; |
| 79 | 84 | // set default words |
| 80 | 85 | $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
@@ -85,7 +90,8 @@ discard block |
||
| 85 | 90 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
| 86 | 91 | } |
| 87 | 92 | |
| 88 | - public function draw_text() { |
|
| 93 | + public function draw_text() |
|
| 94 | + { |
|
| 89 | 95 | $dir = dir($this->dir_font); |
| 90 | 96 | $fontstmp = array(); |
| 91 | 97 | while (false !== ($file = $dir->read())) { |
@@ -140,7 +146,8 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | |
| 142 | 148 | |
| 143 | - public function draw_image() { |
|
| 149 | + public function draw_image() |
|
| 150 | + { |
|
| 144 | 151 | |
| 145 | 152 | /* pick one background image randomly from image directory */ |
| 146 | 153 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -171,7 +178,8 @@ discard block |
||
| 171 | 178 | return $this->im; |
| 172 | 179 | } |
| 173 | 180 | |
| 174 | - public function destroy_image() { |
|
| 181 | + public function destroy_image() |
|
| 182 | + { |
|
| 175 | 183 | |
| 176 | 184 | imagedestroy($this->im); |
| 177 | 185 | |
@@ -344,7 +344,7 @@ |
||
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * @param string $filepath |
| 347 | - * @return bool|string |
|
| 347 | + * @return null|string |
|
| 348 | 348 | */ |
| 349 | 349 | function getFileContent($filepath) { |
| 350 | 350 | global $_lang; |
@@ -1,17 +1,17 @@ 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 | if(!$modx->hasPermission('import_static')) { |
| 6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Files to upload |
| 10 | 10 | $allowedfiles = array( |
| 11 | - 'html', |
|
| 12 | - 'htm', |
|
| 13 | - 'shtml', |
|
| 14 | - 'xml' |
|
| 11 | + 'html', |
|
| 12 | + 'htm', |
|
| 13 | + 'shtml', |
|
| 14 | + 'xml' |
|
| 15 | 15 | ); |
| 16 | 16 | ?> |
| 17 | 17 | <script language="javascript"> |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | - ?> |
|
| 46 | + if(!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 48 | + ?> |
|
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
| 51 | 51 | <input type="hidden" name="a" value="95" /> |
@@ -85,18 +85,18 @@ discard block |
||
| 85 | 85 | <a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a> |
| 86 | 86 | </form> |
| 87 | 87 | <?php |
| 88 | - } else { |
|
| 89 | - run(); |
|
| 90 | - $modx->clearCache('full'); |
|
| 91 | - ?> |
|
| 88 | + } else { |
|
| 89 | + run(); |
|
| 90 | + $modx->clearCache('full'); |
|
| 91 | + ?> |
|
| 92 | 92 | <a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a> |
| 93 | 93 | <script type="text/javascript"> |
| 94 | 94 | top.mainMenu.reloadtree(); |
| 95 | 95 | parent.tree.ca = 'open'; |
| 96 | 96 | </script> |
| 97 | 97 | <?php |
| 98 | - } |
|
| 99 | - ?> |
|
| 98 | + } |
|
| 99 | + ?> |
|
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | |
@@ -105,64 +105,64 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function run() { |
| 108 | - global $modx, $_lang; |
|
| 108 | + global $modx, $_lang; |
|
| 109 | 109 | |
| 110 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 111 | - $output = ''; |
|
| 112 | - $maxtime = $_POST['maxtime']; |
|
| 110 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 111 | + $output = ''; |
|
| 112 | + $maxtime = $_POST['maxtime']; |
|
| 113 | 113 | |
| 114 | - if(!is_numeric($maxtime)) { |
|
| 115 | - $maxtime = 30; |
|
| 116 | - } |
|
| 114 | + if(!is_numeric($maxtime)) { |
|
| 115 | + $maxtime = 30; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - @set_time_limit($maxtime); |
|
| 118 | + @set_time_limit($maxtime); |
|
| 119 | 119 | |
| 120 | - $mtime = microtime(); |
|
| 121 | - $mtime = explode(' ', $mtime); |
|
| 122 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 123 | - $importstart = $mtime; |
|
| 120 | + $mtime = microtime(); |
|
| 121 | + $mtime = explode(' ', $mtime); |
|
| 122 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 123 | + $importstart = $mtime; |
|
| 124 | 124 | |
| 125 | - if($_POST['reset'] == 'on') { |
|
| 126 | - $modx->db->truncate($tbl_site_content); |
|
| 127 | - $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 128 | - } |
|
| 125 | + if($_POST['reset'] == 'on') { |
|
| 126 | + $modx->db->truncate($tbl_site_content); |
|
| 127 | + $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - $parent = (int)$_POST['parent']; |
|
| 130 | + $parent = (int)$_POST['parent']; |
|
| 131 | 131 | |
| 132 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 136 | - } else { |
|
| 132 | + if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | + $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | + } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | + $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 136 | + } else { |
|
| 137 | 137 | $filedir = ''; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $filesfound = 0; |
|
| 140 | + $filesfound = 0; |
|
| 141 | 141 | |
| 142 | - $files = getFiles($filedir); |
|
| 143 | - $files = pop_index($files); |
|
| 142 | + $files = getFiles($filedir); |
|
| 143 | + $files = pop_index($files); |
|
| 144 | 144 | |
| 145 | - // no. of files to import |
|
| 146 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 145 | + // no. of files to import |
|
| 146 | + $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 147 | 147 | |
| 148 | - // import files |
|
| 149 | - if(0 < count($files)) { |
|
| 150 | - $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 151 | - importFiles($parent, $filedir, $files, 'root'); |
|
| 152 | - } |
|
| 148 | + // import files |
|
| 149 | + if(0 < count($files)) { |
|
| 150 | + $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
|
| 151 | + importFiles($parent, $filedir, $files, 'root'); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - $mtime = microtime(); |
|
| 155 | - $mtime = explode(' ', $mtime); |
|
| 156 | - $mtime = $mtime[1] + $mtime[0]; |
|
| 157 | - $importend = $mtime; |
|
| 158 | - $totaltime = ($importend - $importstart); |
|
| 159 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 154 | + $mtime = microtime(); |
|
| 155 | + $mtime = explode(' ', $mtime); |
|
| 156 | + $mtime = $mtime[1] + $mtime[0]; |
|
| 157 | + $importend = $mtime; |
|
| 158 | + $totaltime = ($importend - $importstart); |
|
| 159 | + $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 160 | 160 | |
| 161 | - if($_POST['convert_link'] == 'on') { |
|
| 162 | - convertLink(); |
|
| 163 | - } |
|
| 161 | + if($_POST['convert_link'] == 'on') { |
|
| 162 | + convertLink(); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return $output; |
|
| 165 | + return $output; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -172,144 +172,144 @@ discard block |
||
| 172 | 172 | * @param string $mode |
| 173 | 173 | */ |
| 174 | 174 | function importFiles($parent, $filedir, $files, $mode) { |
| 175 | - global $modx; |
|
| 176 | - global $_lang, $allowedfiles; |
|
| 177 | - global $search_default, $cache_default, $publish_default; |
|
| 178 | - |
|
| 179 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 180 | - $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 181 | - |
|
| 182 | - $createdby = $modx->getLoginUserID(); |
|
| 183 | - if(!is_array($files)) { |
|
| 184 | - return; |
|
| 185 | - } |
|
| 186 | - if($_POST['object'] === 'all') { |
|
| 187 | - $modx->config['default_template'] = '0'; |
|
| 188 | - $richtext = '0'; |
|
| 189 | - } else { |
|
| 190 | - $richtext = '1'; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - foreach($files as $id => $value) { |
|
| 194 | - if(is_array($value)) { |
|
| 195 | - // create folder |
|
| 196 | - $alias = $id; |
|
| 197 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 198 | - $field = array(); |
|
| 199 | - $field['type'] = 'document'; |
|
| 200 | - $field['contentType'] = 'text/html'; |
|
| 201 | - $field['published'] = $publish_default; |
|
| 202 | - $field['parent'] = $parent; |
|
| 203 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 204 | - $field['richtext'] = $richtext; |
|
| 205 | - $field['template'] = $modx->config['default_template']; |
|
| 206 | - $field['searchable'] = $search_default; |
|
| 207 | - $field['cacheable'] = $cache_default; |
|
| 208 | - $field['createdby'] = $createdby; |
|
| 209 | - $field['isfolder'] = 1; |
|
| 210 | - $field['menuindex'] = 1; |
|
| 211 | - $find = false; |
|
| 212 | - foreach(array( |
|
| 213 | - 'index.html', |
|
| 214 | - 'index.htm' |
|
| 215 | - ) as $filename) { |
|
| 216 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | - if($find === false && file_exists($filepath)) { |
|
| 218 | - $file = getFileContent($filepath); |
|
| 219 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 220 | - |
|
| 221 | - $date = filemtime($filepath); |
|
| 222 | - $field['pagetitle'] = $pagetitle; |
|
| 223 | - $field['longtitle'] = $pagetitle; |
|
| 224 | - $field['description'] = $description; |
|
| 225 | - $field['content'] = $modx->db->escape($content); |
|
| 226 | - $field['createdon'] = $date; |
|
| 227 | - $field['editedon'] = $date; |
|
| 228 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 229 | - if($newid) { |
|
| 230 | - $find = true; |
|
| 231 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 233 | - } else { |
|
| 234 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 235 | - exit; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - if($find === false) { |
|
| 240 | - $date = time(); |
|
| 241 | - $field['pagetitle'] = '---'; |
|
| 242 | - $field['content'] = ''; |
|
| 243 | - $field['createdon'] = $date; |
|
| 244 | - $field['editedon'] = $date; |
|
| 245 | - $field['hidemenu'] = '1'; |
|
| 246 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 247 | - if($newid) { |
|
| 248 | - $find = true; |
|
| 249 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 251 | - } else { |
|
| 252 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 253 | - exit; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } else { |
|
| 257 | - // create document |
|
| 258 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 259 | - continue; |
|
| 260 | - } |
|
| 261 | - $filename = $value; |
|
| 262 | - $fparts = explode('.', $value); |
|
| 263 | - $alias = $fparts[0]; |
|
| 264 | - $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 265 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 266 | - |
|
| 267 | - if(!in_array($ext, $allowedfiles)) { |
|
| 268 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 269 | - } else { |
|
| 270 | - $filepath = $filedir . $filename; |
|
| 271 | - $file = getFileContent($filepath); |
|
| 272 | - list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 273 | - |
|
| 274 | - $date = filemtime($filepath); |
|
| 275 | - $field = array(); |
|
| 276 | - $field['type'] = 'document'; |
|
| 277 | - $field['contentType'] = 'text/html'; |
|
| 278 | - $field['pagetitle'] = $pagetitle; |
|
| 279 | - $field['longtitle'] = $pagetitle; |
|
| 280 | - $field['description'] = $description; |
|
| 281 | - $field['alias'] = $modx->stripAlias($alias); |
|
| 282 | - $field['published'] = $publish_default; |
|
| 283 | - $field['parent'] = $parent; |
|
| 284 | - $field['content'] = $modx->db->escape($content); |
|
| 285 | - $field['richtext'] = $richtext; |
|
| 286 | - $field['template'] = $modx->config['default_template']; |
|
| 287 | - $field['searchable'] = $search_default; |
|
| 288 | - $field['cacheable'] = $cache_default; |
|
| 289 | - $field['createdby'] = $createdby; |
|
| 290 | - $field['createdon'] = $date; |
|
| 291 | - $field['editedon'] = $date; |
|
| 292 | - $field['isfolder'] = 0; |
|
| 293 | - $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 294 | - $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 295 | - if($newid) { |
|
| 296 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 297 | - } else { |
|
| 298 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 299 | - exit; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $is_site_start = false; |
|
| 303 | - if($filename == 'index.html') { |
|
| 304 | - $is_site_start = true; |
|
| 305 | - } |
|
| 306 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | - $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 308 | - $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 175 | + global $modx; |
|
| 176 | + global $_lang, $allowedfiles; |
|
| 177 | + global $search_default, $cache_default, $publish_default; |
|
| 178 | + |
|
| 179 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 180 | + $tbl_system_settings = $modx->getFullTableName('system_settings'); |
|
| 181 | + |
|
| 182 | + $createdby = $modx->getLoginUserID(); |
|
| 183 | + if(!is_array($files)) { |
|
| 184 | + return; |
|
| 185 | + } |
|
| 186 | + if($_POST['object'] === 'all') { |
|
| 187 | + $modx->config['default_template'] = '0'; |
|
| 188 | + $richtext = '0'; |
|
| 189 | + } else { |
|
| 190 | + $richtext = '1'; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + foreach($files as $id => $value) { |
|
| 194 | + if(is_array($value)) { |
|
| 195 | + // create folder |
|
| 196 | + $alias = $id; |
|
| 197 | + printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 198 | + $field = array(); |
|
| 199 | + $field['type'] = 'document'; |
|
| 200 | + $field['contentType'] = 'text/html'; |
|
| 201 | + $field['published'] = $publish_default; |
|
| 202 | + $field['parent'] = $parent; |
|
| 203 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 204 | + $field['richtext'] = $richtext; |
|
| 205 | + $field['template'] = $modx->config['default_template']; |
|
| 206 | + $field['searchable'] = $search_default; |
|
| 207 | + $field['cacheable'] = $cache_default; |
|
| 208 | + $field['createdby'] = $createdby; |
|
| 209 | + $field['isfolder'] = 1; |
|
| 210 | + $field['menuindex'] = 1; |
|
| 211 | + $find = false; |
|
| 212 | + foreach(array( |
|
| 213 | + 'index.html', |
|
| 214 | + 'index.htm' |
|
| 215 | + ) as $filename) { |
|
| 216 | + $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | + if($find === false && file_exists($filepath)) { |
|
| 218 | + $file = getFileContent($filepath); |
|
| 219 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 220 | + |
|
| 221 | + $date = filemtime($filepath); |
|
| 222 | + $field['pagetitle'] = $pagetitle; |
|
| 223 | + $field['longtitle'] = $pagetitle; |
|
| 224 | + $field['description'] = $description; |
|
| 225 | + $field['content'] = $modx->db->escape($content); |
|
| 226 | + $field['createdon'] = $date; |
|
| 227 | + $field['editedon'] = $date; |
|
| 228 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 229 | + if($newid) { |
|
| 230 | + $find = true; |
|
| 231 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 233 | + } else { |
|
| 234 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 235 | + exit; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + if($find === false) { |
|
| 240 | + $date = time(); |
|
| 241 | + $field['pagetitle'] = '---'; |
|
| 242 | + $field['content'] = ''; |
|
| 243 | + $field['createdon'] = $date; |
|
| 244 | + $field['editedon'] = $date; |
|
| 245 | + $field['hidemenu'] = '1'; |
|
| 246 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 247 | + if($newid) { |
|
| 248 | + $find = true; |
|
| 249 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | + importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 251 | + } else { |
|
| 252 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 253 | + exit; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } else { |
|
| 257 | + // create document |
|
| 258 | + if($mode == 'sub' && $value == 'index.html') { |
|
| 259 | + continue; |
|
| 260 | + } |
|
| 261 | + $filename = $value; |
|
| 262 | + $fparts = explode('.', $value); |
|
| 263 | + $alias = $fparts[0]; |
|
| 264 | + $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
|
| 265 | + printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 266 | + |
|
| 267 | + if(!in_array($ext, $allowedfiles)) { |
|
| 268 | + echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 269 | + } else { |
|
| 270 | + $filepath = $filedir . $filename; |
|
| 271 | + $file = getFileContent($filepath); |
|
| 272 | + list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
|
| 273 | + |
|
| 274 | + $date = filemtime($filepath); |
|
| 275 | + $field = array(); |
|
| 276 | + $field['type'] = 'document'; |
|
| 277 | + $field['contentType'] = 'text/html'; |
|
| 278 | + $field['pagetitle'] = $pagetitle; |
|
| 279 | + $field['longtitle'] = $pagetitle; |
|
| 280 | + $field['description'] = $description; |
|
| 281 | + $field['alias'] = $modx->stripAlias($alias); |
|
| 282 | + $field['published'] = $publish_default; |
|
| 283 | + $field['parent'] = $parent; |
|
| 284 | + $field['content'] = $modx->db->escape($content); |
|
| 285 | + $field['richtext'] = $richtext; |
|
| 286 | + $field['template'] = $modx->config['default_template']; |
|
| 287 | + $field['searchable'] = $search_default; |
|
| 288 | + $field['cacheable'] = $cache_default; |
|
| 289 | + $field['createdby'] = $createdby; |
|
| 290 | + $field['createdon'] = $date; |
|
| 291 | + $field['editedon'] = $date; |
|
| 292 | + $field['isfolder'] = 0; |
|
| 293 | + $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
|
| 294 | + $newid = $modx->db->insert($field, $tbl_site_content); |
|
| 295 | + if($newid) { |
|
| 296 | + echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 297 | + } else { |
|
| 298 | + echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 299 | + exit; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $is_site_start = false; |
|
| 303 | + if($filename == 'index.html') { |
|
| 304 | + $is_site_start = true; |
|
| 305 | + } |
|
| 306 | + if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | + $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
|
| 308 | + $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -319,27 +319,27 @@ discard block |
||
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | 321 | function getFiles($directory, $listing = array(), $count = 0) { |
| 322 | - global $_lang; |
|
| 323 | - global $filesfound; |
|
| 324 | - $dummy = $count; |
|
| 325 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | - foreach($files as $file) { |
|
| 327 | - if($file == '.' || $file == '..') { |
|
| 328 | - continue; |
|
| 329 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 330 | - closedir($h); |
|
| 331 | - $count = -1; |
|
| 332 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 334 | - $listing[$dummy] = $file; |
|
| 335 | - $dummy = $dummy + 1; |
|
| 336 | - $filesfound++; |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } else { |
|
| 340 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 341 | - } |
|
| 342 | - return ($listing); |
|
| 322 | + global $_lang; |
|
| 323 | + global $filesfound; |
|
| 324 | + $dummy = $count; |
|
| 325 | + if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | + foreach($files as $file) { |
|
| 327 | + if($file == '.' || $file == '..') { |
|
| 328 | + continue; |
|
| 329 | + } elseif($h = @opendir($directory . $file . "/")) { |
|
| 330 | + closedir($h); |
|
| 331 | + $count = -1; |
|
| 332 | + $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | + } elseif(strpos($file, '.htm') !== false) { |
|
| 334 | + $listing[$dummy] = $file; |
|
| 335 | + $dummy = $dummy + 1; |
|
| 336 | + $filesfound++; |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } else { |
|
| 340 | + echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 341 | + } |
|
| 342 | + return ($listing); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | * @return bool|string |
| 348 | 348 | */ |
| 349 | 349 | function getFileContent($filepath) { |
| 350 | - global $_lang; |
|
| 351 | - // get the file |
|
| 352 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 354 | - } else { |
|
| 355 | - return $buffer; |
|
| 356 | - } |
|
| 350 | + global $_lang; |
|
| 351 | + // get the file |
|
| 352 | + if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | + echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 354 | + } else { |
|
| 355 | + return $buffer; |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -361,20 +361,20 @@ discard block |
||
| 361 | 361 | * @return array |
| 362 | 362 | */ |
| 363 | 363 | function pop_index($array) { |
| 364 | - $new_array = array(); |
|
| 365 | - foreach($array as $k => $v) { |
|
| 366 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | - $new_array[$k] = $v; |
|
| 368 | - } else { |
|
| 369 | - array_unshift($new_array, $v); |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - foreach($array as $k => $v) { |
|
| 373 | - if(is_array($v)) { |
|
| 374 | - $new_array[$k] = $v; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - return $new_array; |
|
| 364 | + $new_array = array(); |
|
| 365 | + foreach($array as $k => $v) { |
|
| 366 | + if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | + $new_array[$k] = $v; |
|
| 368 | + } else { |
|
| 369 | + array_unshift($new_array, $v); |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | + foreach($array as $k => $v) { |
|
| 373 | + if(is_array($v)) { |
|
| 374 | + $new_array[$k] = $v; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + return $new_array; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -384,108 +384,108 @@ discard block |
||
| 384 | 384 | * @return array |
| 385 | 385 | */ |
| 386 | 386 | function treatContent($src, $filename, $alias) { |
| 387 | - global $modx; |
|
| 388 | - |
|
| 389 | - $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 390 | - |
|
| 391 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | - $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 393 | - $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 394 | - } else { |
|
| 395 | - $pagetitle = $alias; |
|
| 396 | - } |
|
| 397 | - if(!$pagetitle) { |
|
| 398 | - $pagetitle = $alias; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | - $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 403 | - $description = str_replace('[*description*]', '', $description); |
|
| 404 | - } else { |
|
| 405 | - $description = ''; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | - $content = $matches[1]; |
|
| 410 | - } else { |
|
| 411 | - $content = $src; |
|
| 412 | - $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 413 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 414 | - $content = preg_replace($s, $r, $content); |
|
| 415 | - $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 416 | - } |
|
| 417 | - $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 418 | - $content = trim($content); |
|
| 419 | - $pagetitle = $modx->db->escape($pagetitle); |
|
| 420 | - return array( |
|
| 421 | - $pagetitle, |
|
| 422 | - $content, |
|
| 423 | - $description |
|
| 424 | - ); |
|
| 387 | + global $modx; |
|
| 388 | + |
|
| 389 | + $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
|
| 390 | + |
|
| 391 | + if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | + $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 393 | + $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
|
| 394 | + } else { |
|
| 395 | + $pagetitle = $alias; |
|
| 396 | + } |
|
| 397 | + if(!$pagetitle) { |
|
| 398 | + $pagetitle = $alias; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | + $description = ($matches[1] !== '') ? $matches[1] : $filename; |
|
| 403 | + $description = str_replace('[*description*]', '', $description); |
|
| 404 | + } else { |
|
| 405 | + $description = ''; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | + $content = $matches[1]; |
|
| 410 | + } else { |
|
| 411 | + $content = $src; |
|
| 412 | + $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
|
| 413 | + $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 414 | + $content = preg_replace($s, $r, $content); |
|
| 415 | + $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
|
| 416 | + } |
|
| 417 | + $content = str_replace('[*content*]', '[ *content* ]', $content); |
|
| 418 | + $content = trim($content); |
|
| 419 | + $pagetitle = $modx->db->escape($pagetitle); |
|
| 420 | + return array( |
|
| 421 | + $pagetitle, |
|
| 422 | + $content, |
|
| 423 | + $description |
|
| 424 | + ); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | 430 | function convertLink() { |
| 431 | - global $modx; |
|
| 432 | - $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 431 | + global $modx; |
|
| 432 | + $tbl_site_content = $modx->getFullTableName('site_content'); |
|
| 433 | 433 | |
| 434 | - $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 435 | - $p = array(); |
|
| 434 | + $rs = $modx->db->select('id,content', $tbl_site_content); |
|
| 435 | + $p = array(); |
|
| 436 | 436 | $target = array(); |
| 437 | - $dir = ''; |
|
| 438 | - while($row = $modx->db->getRow($rs)) { |
|
| 439 | - $id = $row['id']; |
|
| 440 | - $array = explode('<a href=', $row['content']); |
|
| 441 | - $c = 0; |
|
| 442 | - foreach($array as $v) { |
|
| 443 | - if($v[0] === '"') { |
|
| 444 | - $v = substr($v, 1); |
|
| 445 | - list($href, $v) = explode('"', $v, 2); |
|
| 446 | - $_ = $href; |
|
| 447 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 449 | - } |
|
| 450 | - if($_[0] === '/') { |
|
| 451 | - $_ = substr($_, 1); |
|
| 452 | - } |
|
| 453 | - $_ = str_replace('/index.html', '.html', $_); |
|
| 454 | - $level = substr_count($_, '../'); |
|
| 455 | - if(1 < $level) { |
|
| 456 | - if(!isset($p[$id])) { |
|
| 457 | - $p[$id] = $modx->getParentIds($id); |
|
| 458 | - } |
|
| 459 | - $k = array_keys($p[$id]); |
|
| 460 | - while(0 < $level) { |
|
| 461 | - $dir = array_shift($k); |
|
| 462 | - $level--; |
|
| 463 | - } |
|
| 464 | - if($dir != '') { |
|
| 465 | - $dir .= '/'; |
|
| 466 | - } |
|
| 467 | - } else { |
|
| 468 | - $dir = ''; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - $_ = trim($_, './'); |
|
| 472 | - if(strpos($_, '/') !== false) { |
|
| 473 | - $_ = substr($_, strrpos($_, '/')); |
|
| 474 | - } |
|
| 475 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | - if(!isset($target[$_])) { |
|
| 477 | - $target[$_] = $modx->getIdFromAlias($_); |
|
| 478 | - } |
|
| 479 | - $target[$_] = trim($target[$_]); |
|
| 480 | - if(!empty($target[$_])) { |
|
| 481 | - $href = '[~' . $target[$_] . '~]'; |
|
| 482 | - } |
|
| 483 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 484 | - } |
|
| 485 | - $c++; |
|
| 486 | - } |
|
| 487 | - $content = implode('', $array); |
|
| 488 | - $f['content'] = $modx->db->escape($content); |
|
| 489 | - $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 490 | - } |
|
| 437 | + $dir = ''; |
|
| 438 | + while($row = $modx->db->getRow($rs)) { |
|
| 439 | + $id = $row['id']; |
|
| 440 | + $array = explode('<a href=', $row['content']); |
|
| 441 | + $c = 0; |
|
| 442 | + foreach($array as $v) { |
|
| 443 | + if($v[0] === '"') { |
|
| 444 | + $v = substr($v, 1); |
|
| 445 | + list($href, $v) = explode('"', $v, 2); |
|
| 446 | + $_ = $href; |
|
| 447 | + if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | + $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 449 | + } |
|
| 450 | + if($_[0] === '/') { |
|
| 451 | + $_ = substr($_, 1); |
|
| 452 | + } |
|
| 453 | + $_ = str_replace('/index.html', '.html', $_); |
|
| 454 | + $level = substr_count($_, '../'); |
|
| 455 | + if(1 < $level) { |
|
| 456 | + if(!isset($p[$id])) { |
|
| 457 | + $p[$id] = $modx->getParentIds($id); |
|
| 458 | + } |
|
| 459 | + $k = array_keys($p[$id]); |
|
| 460 | + while(0 < $level) { |
|
| 461 | + $dir = array_shift($k); |
|
| 462 | + $level--; |
|
| 463 | + } |
|
| 464 | + if($dir != '') { |
|
| 465 | + $dir .= '/'; |
|
| 466 | + } |
|
| 467 | + } else { |
|
| 468 | + $dir = ''; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + $_ = trim($_, './'); |
|
| 472 | + if(strpos($_, '/') !== false) { |
|
| 473 | + $_ = substr($_, strrpos($_, '/')); |
|
| 474 | + } |
|
| 475 | + $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | + if(!isset($target[$_])) { |
|
| 477 | + $target[$_] = $modx->getIdFromAlias($_); |
|
| 478 | + } |
|
| 479 | + $target[$_] = trim($target[$_]); |
|
| 480 | + if(!empty($target[$_])) { |
|
| 481 | + $href = '[~' . $target[$_] . '~]'; |
|
| 482 | + } |
|
| 483 | + $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 484 | + } |
|
| 485 | + $c++; |
|
| 486 | + } |
|
| 487 | + $content = implode('', $array); |
|
| 488 | + $f['content'] = $modx->db->escape($content); |
|
| 489 | + $modx->db->update($f, $tbl_site_content, "id='{$id}'"); |
|
| 490 | + } |
|
| 491 | 491 | } |
@@ -1,8 +1,8 @@ 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('import_static')) { |
|
| 5 | +if (!$modx->hasPermission('import_static')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | <div class="tab-page"> |
| 44 | 44 | <div class="container container-body"> |
| 45 | 45 | <?php |
| 46 | - if(!isset($_POST['import'])) { |
|
| 47 | - echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; |
|
| 46 | + if (!isset($_POST['import'])) { |
|
| 47 | + echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; |
|
| 48 | 48 | ?> |
| 49 | 49 | <form action="index.php" method="post" name="importFrm"> |
| 50 | 50 | <input type="hidden" name="import" value="import" /> |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | -function run() { |
|
| 107 | +function run(){ |
|
| 108 | 108 | global $modx, $_lang; |
| 109 | 109 | |
| 110 | 110 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 111 | 111 | $output = ''; |
| 112 | 112 | $maxtime = $_POST['maxtime']; |
| 113 | 113 | |
| 114 | - if(!is_numeric($maxtime)) { |
|
| 114 | + if (!is_numeric($maxtime)) { |
|
| 115 | 115 | $maxtime = 30; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | $mtime = $mtime[1] + $mtime[0]; |
| 123 | 123 | $importstart = $mtime; |
| 124 | 124 | |
| 125 | - if($_POST['reset'] == 'on') { |
|
| 125 | + if ($_POST['reset'] == 'on') { |
|
| 126 | 126 | $modx->db->truncate($tbl_site_content); |
| 127 | 127 | $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1"); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $parent = (int)$_POST['parent']; |
|
| 130 | + $parent = (int) $_POST['parent']; |
|
| 131 | 131 | |
| 132 | - if(is_dir(MODX_BASE_PATH . 'temp/import')) { |
|
| 133 | - $filedir = MODX_BASE_PATH . 'temp/import/'; |
|
| 134 | - } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) { |
|
| 135 | - $filedir = MODX_BASE_PATH . 'assets/import/'; |
|
| 132 | + if (is_dir(MODX_BASE_PATH.'temp/import')) { |
|
| 133 | + $filedir = MODX_BASE_PATH.'temp/import/'; |
|
| 134 | + } elseif (is_dir(MODX_BASE_PATH.'assets/import')) { |
|
| 135 | + $filedir = MODX_BASE_PATH.'assets/import/'; |
|
| 136 | 136 | } else { |
| 137 | 137 | $filedir = ''; |
| 138 | 138 | } |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $files = pop_index($files); |
| 144 | 144 | |
| 145 | 145 | // no. of files to import |
| 146 | - $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound); |
|
| 146 | + $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound); |
|
| 147 | 147 | |
| 148 | 148 | // import files |
| 149 | - if(0 < count($files)) { |
|
| 149 | + if (0 < count($files)) { |
|
| 150 | 150 | $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'"); |
| 151 | 151 | importFiles($parent, $filedir, $files, 'root'); |
| 152 | 152 | } |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | $mtime = $mtime[1] + $mtime[0]; |
| 157 | 157 | $importend = $mtime; |
| 158 | 158 | $totaltime = ($importend - $importstart); |
| 159 | - $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3)); |
|
| 159 | + $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3)); |
|
| 160 | 160 | |
| 161 | - if($_POST['convert_link'] == 'on') { |
|
| 161 | + if ($_POST['convert_link'] == 'on') { |
|
| 162 | 162 | convertLink(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param array $files |
| 172 | 172 | * @param string $mode |
| 173 | 173 | */ |
| 174 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 174 | +function importFiles($parent, $filedir, $files, $mode){ |
|
| 175 | 175 | global $modx; |
| 176 | 176 | global $_lang, $allowedfiles; |
| 177 | 177 | global $search_default, $cache_default, $publish_default; |
@@ -180,21 +180,21 @@ discard block |
||
| 180 | 180 | $tbl_system_settings = $modx->getFullTableName('system_settings'); |
| 181 | 181 | |
| 182 | 182 | $createdby = $modx->getLoginUserID(); |
| 183 | - if(!is_array($files)) { |
|
| 183 | + if (!is_array($files)) { |
|
| 184 | 184 | return; |
| 185 | 185 | } |
| 186 | - if($_POST['object'] === 'all') { |
|
| 186 | + if ($_POST['object'] === 'all') { |
|
| 187 | 187 | $modx->config['default_template'] = '0'; |
| 188 | 188 | $richtext = '0'; |
| 189 | 189 | } else { |
| 190 | 190 | $richtext = '1'; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - foreach($files as $id => $value) { |
|
| 194 | - if(is_array($value)) { |
|
| 193 | + foreach ($files as $id => $value) { |
|
| 194 | + if (is_array($value)) { |
|
| 195 | 195 | // create folder |
| 196 | 196 | $alias = $id; |
| 197 | - printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias); |
|
| 197 | + printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias); |
|
| 198 | 198 | $field = array(); |
| 199 | 199 | $field['type'] = 'document'; |
| 200 | 200 | $field['contentType'] = 'text/html'; |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | $field['isfolder'] = 1; |
| 210 | 210 | $field['menuindex'] = 1; |
| 211 | 211 | $find = false; |
| 212 | - foreach(array( |
|
| 212 | + foreach (array( |
|
| 213 | 213 | 'index.html', |
| 214 | 214 | 'index.htm' |
| 215 | 215 | ) as $filename) { |
| 216 | - $filepath = $filedir . $alias . '/' . $filename; |
|
| 217 | - if($find === false && file_exists($filepath)) { |
|
| 216 | + $filepath = $filedir.$alias.'/'.$filename; |
|
| 217 | + if ($find === false && file_exists($filepath)) { |
|
| 218 | 218 | $file = getFileContent($filepath); |
| 219 | 219 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 220 | 220 | |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | $field['createdon'] = $date; |
| 227 | 227 | $field['editedon'] = $date; |
| 228 | 228 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 229 | - if($newid) { |
|
| 229 | + if ($newid) { |
|
| 230 | 230 | $find = true; |
| 231 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 232 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 231 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 232 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 233 | 233 | } else { |
| 234 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 234 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 235 | 235 | exit; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | - if($find === false) { |
|
| 239 | + if ($find === false) { |
|
| 240 | 240 | $date = time(); |
| 241 | 241 | $field['pagetitle'] = '---'; |
| 242 | 242 | $field['content'] = ''; |
@@ -244,30 +244,30 @@ discard block |
||
| 244 | 244 | $field['editedon'] = $date; |
| 245 | 245 | $field['hidemenu'] = '1'; |
| 246 | 246 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 247 | - if($newid) { |
|
| 247 | + if ($newid) { |
|
| 248 | 248 | $find = true; |
| 249 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 250 | - importFiles($newid, $filedir . $alias . '/', $value, 'sub'); |
|
| 249 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 250 | + importFiles($newid, $filedir.$alias.'/', $value, 'sub'); |
|
| 251 | 251 | } else { |
| 252 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 252 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 253 | 253 | exit; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } else { |
| 257 | 257 | // create document |
| 258 | - if($mode == 'sub' && $value == 'index.html') { |
|
| 258 | + if ($mode == 'sub' && $value == 'index.html') { |
|
| 259 | 259 | continue; |
| 260 | 260 | } |
| 261 | 261 | $filename = $value; |
| 262 | 262 | $fparts = explode('.', $value); |
| 263 | 263 | $alias = $fparts[0]; |
| 264 | 264 | $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : ""; |
| 265 | - printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename); |
|
| 265 | + printf("<span>".$_lang['import_site_importing_document']."</span>", $filename); |
|
| 266 | 266 | |
| 267 | - if(!in_array($ext, $allowedfiles)) { |
|
| 268 | - echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n"; |
|
| 267 | + if (!in_array($ext, $allowedfiles)) { |
|
| 268 | + echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n"; |
|
| 269 | 269 | } else { |
| 270 | - $filepath = $filedir . $filename; |
|
| 270 | + $filepath = $filedir.$filename; |
|
| 271 | 271 | $file = getFileContent($filepath); |
| 272 | 272 | list($pagetitle, $content, $description) = treatContent($file, $filename, $alias); |
| 273 | 273 | |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | $field['isfolder'] = 0; |
| 293 | 293 | $field['menuindex'] = ($alias == 'index') ? 0 : 2; |
| 294 | 294 | $newid = $modx->db->insert($field, $tbl_site_content); |
| 295 | - if($newid) { |
|
| 296 | - echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n"; |
|
| 295 | + if ($newid) { |
|
| 296 | + echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n"; |
|
| 297 | 297 | } else { |
| 298 | - echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError(); |
|
| 298 | + echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError(); |
|
| 299 | 299 | exit; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | $is_site_start = false; |
| 303 | - if($filename == 'index.html') { |
|
| 303 | + if ($filename == 'index.html') { |
|
| 304 | 304 | $is_site_start = true; |
| 305 | 305 | } |
| 306 | - if($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 306 | + if ($is_site_start == true && $_POST['reset'] == 'on') { |
|
| 307 | 307 | $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'"); |
| 308 | 308 | $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'"); |
| 309 | 309 | } |
@@ -318,26 +318,26 @@ discard block |
||
| 318 | 318 | * @param int $count |
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 321 | +function getFiles($directory, $listing = array(), $count = 0){ |
|
| 322 | 322 | global $_lang; |
| 323 | 323 | global $filesfound; |
| 324 | 324 | $dummy = $count; |
| 325 | - if( ! empty($directory) && $files = scandir($directory)) { |
|
| 326 | - foreach($files as $file) { |
|
| 327 | - if($file == '.' || $file == '..') { |
|
| 325 | + if (!empty($directory) && $files = scandir($directory)) { |
|
| 326 | + foreach ($files as $file) { |
|
| 327 | + if ($file == '.' || $file == '..') { |
|
| 328 | 328 | continue; |
| 329 | - } elseif($h = @opendir($directory . $file . "/")) { |
|
| 329 | + } elseif ($h = @opendir($directory.$file."/")) { |
|
| 330 | 330 | closedir($h); |
| 331 | 331 | $count = -1; |
| 332 | - $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1); |
|
| 333 | - } elseif(strpos($file, '.htm') !== false) { |
|
| 332 | + $listing[$file] = getFiles($directory.$file."/", array(), $count + 1); |
|
| 333 | + } elseif (strpos($file, '.htm') !== false) { |
|
| 334 | 334 | $listing[$dummy] = $file; |
| 335 | 335 | $dummy = $dummy + 1; |
| 336 | 336 | $filesfound++; |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } else { |
| 340 | - echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>"; |
|
| 340 | + echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>"; |
|
| 341 | 341 | } |
| 342 | 342 | return ($listing); |
| 343 | 343 | } |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | * @param string $filepath |
| 347 | 347 | * @return bool|string |
| 348 | 348 | */ |
| 349 | -function getFileContent($filepath) { |
|
| 349 | +function getFileContent($filepath){ |
|
| 350 | 350 | global $_lang; |
| 351 | 351 | // get the file |
| 352 | - if(!$buffer = file_get_contents($filepath)) { |
|
| 353 | - echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>"; |
|
| 352 | + if (!$buffer = file_get_contents($filepath)) { |
|
| 353 | + echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>"; |
|
| 354 | 354 | } else { |
| 355 | 355 | return $buffer; |
| 356 | 356 | } |
@@ -360,17 +360,17 @@ discard block |
||
| 360 | 360 | * @param array $array |
| 361 | 361 | * @return array |
| 362 | 362 | */ |
| 363 | -function pop_index($array) { |
|
| 363 | +function pop_index($array){ |
|
| 364 | 364 | $new_array = array(); |
| 365 | - foreach($array as $k => $v) { |
|
| 366 | - if($v !== 'index.html' && $v !== 'index.htm') { |
|
| 365 | + foreach ($array as $k => $v) { |
|
| 366 | + if ($v !== 'index.html' && $v !== 'index.htm') { |
|
| 367 | 367 | $new_array[$k] = $v; |
| 368 | 368 | } else { |
| 369 | 369 | array_unshift($new_array, $v); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | - foreach($array as $k => $v) { |
|
| 373 | - if(is_array($v)) { |
|
| 372 | + foreach ($array as $k => $v) { |
|
| 373 | + if (is_array($v)) { |
|
| 374 | 374 | $new_array[$k] = $v; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -383,34 +383,34 @@ discard block |
||
| 383 | 383 | * @param string $alias |
| 384 | 384 | * @return array |
| 385 | 385 | */ |
| 386 | -function treatContent($src, $filename, $alias) { |
|
| 386 | +function treatContent($src, $filename, $alias){ |
|
| 387 | 387 | global $modx; |
| 388 | 388 | |
| 389 | 389 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
| 390 | 390 | |
| 391 | - if(preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 391 | + if (preg_match("@<title>(.*)</title>@i", $src, $matches)) { |
|
| 392 | 392 | $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename; |
| 393 | 393 | $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle); |
| 394 | 394 | } else { |
| 395 | 395 | $pagetitle = $alias; |
| 396 | 396 | } |
| 397 | - if(!$pagetitle) { |
|
| 397 | + if (!$pagetitle) { |
|
| 398 | 398 | $pagetitle = $alias; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 401 | + if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) { |
|
| 402 | 402 | $description = ($matches[1] !== '') ? $matches[1] : $filename; |
| 403 | 403 | $description = str_replace('[*description*]', '', $description); |
| 404 | 404 | } else { |
| 405 | 405 | $description = ''; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 408 | + if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') { |
|
| 409 | 409 | $content = $matches[1]; |
| 410 | 410 | } else { |
| 411 | 411 | $content = $src; |
| 412 | 412 | $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i'; |
| 413 | - $r = '$1' . $modx->config['modx_charset'] . '$2'; |
|
| 413 | + $r = '$1'.$modx->config['modx_charset'].'$2'; |
|
| 414 | 414 | $content = preg_replace($s, $r, $content); |
| 415 | 415 | $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content); |
| 416 | 416 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | /** |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | -function convertLink() { |
|
| 430 | +function convertLink(){ |
|
| 431 | 431 | global $modx; |
| 432 | 432 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 433 | 433 | |
@@ -435,33 +435,33 @@ discard block |
||
| 435 | 435 | $p = array(); |
| 436 | 436 | $target = array(); |
| 437 | 437 | $dir = ''; |
| 438 | - while($row = $modx->db->getRow($rs)) { |
|
| 438 | + while ($row = $modx->db->getRow($rs)) { |
|
| 439 | 439 | $id = $row['id']; |
| 440 | 440 | $array = explode('<a href=', $row['content']); |
| 441 | 441 | $c = 0; |
| 442 | - foreach($array as $v) { |
|
| 443 | - if($v[0] === '"') { |
|
| 442 | + foreach ($array as $v) { |
|
| 443 | + if ($v[0] === '"') { |
|
| 444 | 444 | $v = substr($v, 1); |
| 445 | 445 | list($href, $v) = explode('"', $v, 2); |
| 446 | 446 | $_ = $href; |
| 447 | - if(strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | - $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_); |
|
| 447 | + if (strpos($_, $modx->config['site_url']) !== false) { |
|
| 448 | + $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_); |
|
| 449 | 449 | } |
| 450 | - if($_[0] === '/') { |
|
| 450 | + if ($_[0] === '/') { |
|
| 451 | 451 | $_ = substr($_, 1); |
| 452 | 452 | } |
| 453 | 453 | $_ = str_replace('/index.html', '.html', $_); |
| 454 | 454 | $level = substr_count($_, '../'); |
| 455 | - if(1 < $level) { |
|
| 456 | - if(!isset($p[$id])) { |
|
| 455 | + if (1 < $level) { |
|
| 456 | + if (!isset($p[$id])) { |
|
| 457 | 457 | $p[$id] = $modx->getParentIds($id); |
| 458 | 458 | } |
| 459 | 459 | $k = array_keys($p[$id]); |
| 460 | - while(0 < $level) { |
|
| 460 | + while (0 < $level) { |
|
| 461 | 461 | $dir = array_shift($k); |
| 462 | 462 | $level--; |
| 463 | 463 | } |
| 464 | - if($dir != '') { |
|
| 464 | + if ($dir != '') { |
|
| 465 | 465 | $dir .= '/'; |
| 466 | 466 | } |
| 467 | 467 | } else { |
@@ -469,18 +469,18 @@ discard block |
||
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | $_ = trim($_, './'); |
| 472 | - if(strpos($_, '/') !== false) { |
|
| 472 | + if (strpos($_, '/') !== false) { |
|
| 473 | 473 | $_ = substr($_, strrpos($_, '/')); |
| 474 | 474 | } |
| 475 | - $_ = $dir . str_replace('.html', '', $_); |
|
| 476 | - if(!isset($target[$_])) { |
|
| 475 | + $_ = $dir.str_replace('.html', '', $_); |
|
| 476 | + if (!isset($target[$_])) { |
|
| 477 | 477 | $target[$_] = $modx->getIdFromAlias($_); |
| 478 | 478 | } |
| 479 | 479 | $target[$_] = trim($target[$_]); |
| 480 | - if(!empty($target[$_])) { |
|
| 481 | - $href = '[~' . $target[$_] . '~]'; |
|
| 480 | + if (!empty($target[$_])) { |
|
| 481 | + $href = '[~'.$target[$_].'~]'; |
|
| 482 | 482 | } |
| 483 | - $array[$c] = '<a href="' . $href . '"' . $v; |
|
| 483 | + $array[$c] = '<a href="'.$href.'"'.$v; |
|
| 484 | 484 | } |
| 485 | 485 | $c++; |
| 486 | 486 | } |
@@ -104,7 +104,8 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | -function run() { |
|
| 107 | +function run() |
|
| 108 | +{ |
|
| 108 | 109 | global $modx, $_lang; |
| 109 | 110 | |
| 110 | 111 | $tbl_site_content = $modx->getFullTableName('site_content'); |
@@ -171,7 +172,8 @@ discard block |
||
| 171 | 172 | * @param array $files |
| 172 | 173 | * @param string $mode |
| 173 | 174 | */ |
| 174 | -function importFiles($parent, $filedir, $files, $mode) { |
|
| 175 | +function importFiles($parent, $filedir, $files, $mode) |
|
| 176 | +{ |
|
| 175 | 177 | global $modx; |
| 176 | 178 | global $_lang, $allowedfiles; |
| 177 | 179 | global $search_default, $cache_default, $publish_default; |
@@ -318,7 +320,8 @@ discard block |
||
| 318 | 320 | * @param int $count |
| 319 | 321 | * @return array |
| 320 | 322 | */ |
| 321 | -function getFiles($directory, $listing = array(), $count = 0) { |
|
| 323 | +function getFiles($directory, $listing = array(), $count = 0) |
|
| 324 | +{ |
|
| 322 | 325 | global $_lang; |
| 323 | 326 | global $filesfound; |
| 324 | 327 | $dummy = $count; |
@@ -346,7 +349,8 @@ discard block |
||
| 346 | 349 | * @param string $filepath |
| 347 | 350 | * @return bool|string |
| 348 | 351 | */ |
| 349 | -function getFileContent($filepath) { |
|
| 352 | +function getFileContent($filepath) |
|
| 353 | +{ |
|
| 350 | 354 | global $_lang; |
| 351 | 355 | // get the file |
| 352 | 356 | if(!$buffer = file_get_contents($filepath)) { |
@@ -360,7 +364,8 @@ discard block |
||
| 360 | 364 | * @param array $array |
| 361 | 365 | * @return array |
| 362 | 366 | */ |
| 363 | -function pop_index($array) { |
|
| 367 | +function pop_index($array) |
|
| 368 | +{ |
|
| 364 | 369 | $new_array = array(); |
| 365 | 370 | foreach($array as $k => $v) { |
| 366 | 371 | if($v !== 'index.html' && $v !== 'index.htm') { |
@@ -383,7 +388,8 @@ discard block |
||
| 383 | 388 | * @param string $alias |
| 384 | 389 | * @return array |
| 385 | 390 | */ |
| 386 | -function treatContent($src, $filename, $alias) { |
|
| 391 | +function treatContent($src, $filename, $alias) |
|
| 392 | +{ |
|
| 387 | 393 | global $modx; |
| 388 | 394 | |
| 389 | 395 | $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII'); |
@@ -427,7 +433,8 @@ discard block |
||
| 427 | 433 | /** |
| 428 | 434 | * @return void |
| 429 | 435 | */ |
| 430 | -function convertLink() { |
|
| 436 | +function convertLink() |
|
| 437 | +{ |
|
| 431 | 438 | global $modx; |
| 432 | 439 | $tbl_site_content = $modx->getFullTableName('site_content'); |
| 433 | 440 | |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * @param string|array $fields |
|
| 244 | - * @param string|array $from |
|
| 245 | - * @param string|array $where |
|
| 243 | + * @param string $fields |
|
| 244 | + * @param string $from |
|
| 245 | + * @param string $where |
|
| 246 | 246 | * @param string $orderBy |
| 247 | 247 | * @param string $limit |
| 248 | 248 | * @return bool|mysqli_result |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param string $fromtable |
| 327 | 327 | * @param string $where |
| 328 | 328 | * @param string $limit |
| 329 | - * @return mixed |
|
| 329 | + * @return null|integer |
|
| 330 | 330 | */ |
| 331 | 331 | public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "") |
| 332 | 332 | { |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * @param null|mysqli $conn |
| 438 | - * @return mixed |
|
| 438 | + * @return integer |
|
| 439 | 439 | */ |
| 440 | 440 | public function getInsertId($conn = null) |
| 441 | 441 | { |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
| 516 | - * @param $name |
|
| 516 | + * @param string $name |
|
| 517 | 517 | * @param mysqli_result|string $dsq |
| 518 | 518 | * @return array |
| 519 | 519 | */ |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | /** |
| 574 | 574 | * @param string $table |
| 575 | - * @return array |
|
| 575 | + * @return boolean |
|
| 576 | 576 | */ |
| 577 | 577 | public function getTableMetaData($table) |
| 578 | 578 | { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
| 622 | - * @param string|mysqli_result $rs |
|
| 622 | + * @param string $rs |
|
| 623 | 623 | * @param bool $index |
| 624 | 624 | * @return array |
| 625 | 625 | */ |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $pre = null, |
| 31 | 31 | $charset = '', |
| 32 | 32 | $connection_method = 'SET CHARACTER SET' |
| 33 | - ) { |
|
| 33 | + ){ |
|
| 34 | 34 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
| 35 | 35 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
| 36 | 36 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $ua = $modx->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
| 71 | 71 | $referer = $modx->htmlspecialchars($_SERVER['HTTP_REFERER']); |
| 72 | 72 | $modx->sendmail(array( |
| 73 | - 'subject' => 'Missing to create the database connection! from ' . $modx->config['site_name'], |
|
| 73 | + 'subject' => 'Missing to create the database connection! from '.$modx->config['site_name'], |
|
| 74 | 74 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
| 75 | 75 | 'type' => 'text' |
| 76 | 76 | )); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | $tend = $modx->getMicroTime(); |
| 86 | 86 | $totaltime = $tend - $tstart; |
| 87 | 87 | if ($modx->dumpSQL) { |
| 88 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
| 89 | - $totaltime) . "</fieldset><br />"; |
|
| 88 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
| 89 | + $totaltime)."</fieldset><br />"; |
|
| 90 | 90 | } |
| 91 | 91 | $this->conn->set_charset($this->config['charset']); |
| 92 | 92 | $this->isConnected = true; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if (1000 < $safeCount) { |
| 120 | 120 | exit("Too many loops '{$safeCount}'"); |
| 121 | 121 | } |
| 122 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 122 | + if (!($this->conn instanceof mysqli)) { |
|
| 123 | 123 | $this->connect(); |
| 124 | 124 | } |
| 125 | 125 | if (is_array($s)) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function query($sql, $watchError = true) |
| 146 | 146 | { |
| 147 | 147 | global $modx; |
| 148 | - if ( ! ($this->conn instanceof mysqli)) { |
|
| 148 | + if (!($this->conn instanceof mysqli)) { |
|
| 149 | 149 | $this->connect(); |
| 150 | 150 | } |
| 151 | 151 | $tStart = $modx->getMicroTime(); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | case 1091: |
| 166 | 166 | break; |
| 167 | 167 | default: |
| 168 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
| 168 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
| 169 | 169 | } |
| 170 | 170 | } else { |
| 171 | 171 | $tend = $modx->getMicroTime(); |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | $debug_path[] = $line['function']; |
| 180 | 180 | } |
| 181 | 181 | $debug_path = implode(' > ', array_reverse($debug_path)); |
| 182 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
| 183 | - $totalTime * 1000) . "</legend>"; |
|
| 184 | - $modx->queryCode .= $sql . '<br><br>'; |
|
| 182 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
| 183 | + $totalTime * 1000)."</legend>"; |
|
| 184 | + $modx->queryCode .= $sql.'<br><br>'; |
|
| 185 | 185 | if ($modx->event->name) { |
| 186 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
| 186 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
| 187 | 187 | } |
| 188 | 188 | if ($modx->event->activePlugin) { |
| 189 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
| 189 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
| 190 | 190 | } |
| 191 | 191 | if ($modx->currentSnippet) { |
| 192 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
| 192 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
| 193 | 193 | } |
| 194 | 194 | if (stripos($sql, 'select') === 0) { |
| 195 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
| 195 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
| 196 | 196 | } else { |
| 197 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
| 197 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
| 198 | 198 | } |
| 199 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
| 199 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
| 200 | 200 | $modx->queryCode .= "</fieldset><br />"; |
| 201 | 201 | } |
| 202 | 202 | $modx->executedQueries++; |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | if ($value === null || strtolower($value) === 'null') { |
| 304 | 304 | $f = 'NULL'; |
| 305 | 305 | } else { |
| 306 | - $f = "'" . $value . "'"; |
|
| 306 | + $f = "'".$value."'"; |
|
| 307 | 307 | } |
| 308 | - $fields[$key] = "`{$key}` = " . $f; |
|
| 308 | + $fields[$key] = "`{$key}` = ".$f; |
|
| 309 | 309 | } |
| 310 | 310 | $fields = implode(',', $fields); |
| 311 | 311 | } |
@@ -340,12 +340,12 @@ discard block |
||
| 340 | 340 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 341 | 341 | } else { |
| 342 | 342 | if (empty($fromtable)) { |
| 343 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
| 344 | - array_values($fields)) . "')"; |
|
| 343 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
| 344 | + array_values($fields))."')"; |
|
| 345 | 345 | $this->query("INSERT INTO {$intotable} {$fields}"); |
| 346 | 346 | } else { |
| 347 | 347 | $fromtable = $this->replaceFullTableName($fromtable); |
| 348 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
| 348 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
| 349 | 349 | $where = trim($where); |
| 350 | 350 | $limit = trim($limit); |
| 351 | 351 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function getInsertId($conn = null) |
| 441 | 441 | { |
| 442 | - if (! ($conn instanceof mysqli)) { |
|
| 443 | - $conn =& $this->conn; |
|
| 442 | + if (!($conn instanceof mysqli)) { |
|
| 443 | + $conn = & $this->conn; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | return $conn->insert_id; |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function getAffectedRows($conn = null) |
| 454 | 454 | { |
| 455 | - if (! ($conn instanceof mysqli)) { |
|
| 456 | - $conn =& $this->conn; |
|
| 455 | + if (!($conn instanceof mysqli)) { |
|
| 456 | + $conn = & $this->conn; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | return $conn->affected_rows; |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public function getLastError($conn = null) |
| 467 | 467 | { |
| 468 | - if (! ($conn instanceof mysqli)) { |
|
| 469 | - $conn =& $this->conn; |
|
| 468 | + if (!($conn instanceof mysqli)) { |
|
| 469 | + $conn = & $this->conn; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | return $conn->error; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | { |
| 491 | 491 | $out = false; |
| 492 | 492 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 493 | + switch ($mode) { |
|
| 494 | 494 | case 'assoc': |
| 495 | 495 | $out = $ds->fetch_assoc(); |
| 496 | 496 | break; |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | public function getColumn($name, $dsq) |
| 521 | 521 | { |
| 522 | 522 | $col = array(); |
| 523 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 523 | + if (!($dsq instanceof mysqli_result)) { |
|
| 524 | 524 | $dsq = $this->query($dsq); |
| 525 | 525 | } |
| 526 | 526 | if ($dsq) { |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | public function getColumnNames($dsq) |
| 540 | 540 | { |
| 541 | 541 | $names = array(); |
| 542 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 542 | + if (!($dsq instanceof mysqli_result)) { |
|
| 543 | 543 | $dsq = $this->query($dsq); |
| 544 | 544 | } |
| 545 | 545 | if ($dsq) { |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | public function getValue($dsq) |
| 560 | 560 | { |
| 561 | 561 | $out = false; |
| 562 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
| 562 | + if (!($dsq instanceof mysqli_result)) { |
|
| 563 | 563 | $dsq = $this->query($dsq); |
| 564 | 564 | } |
| 565 | 565 | if ($dsq) { |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | $tableName = trim($tableName); |
| 658 | 658 | $dbase = trim($this->config['dbase'], '`'); |
| 659 | 659 | $prefix = $this->config['table_prefix']; |
| 660 | - if ((bool)$force === true) { |
|
| 660 | + if ((bool) $force === true) { |
|
| 661 | 661 | $result = "`{$dbase}`.`{$prefix}{$tableName}`"; |
| 662 | 662 | } elseif (strpos($tableName, '[+prefix+]') !== false) { |
| 663 | 663 | $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName); |
@@ -373,7 +373,8 @@ discard block |
||
| 373 | 373 | * @return bool|mixed|mysqli_result |
| 374 | 374 | */ |
| 375 | 375 | public function save($fields, $table, $where = '') |
| 376 | - { // This is similar to "replace into table". |
|
| 376 | + { |
|
| 377 | +// This is similar to "replace into table". |
|
| 377 | 378 | |
| 378 | 379 | if ($where === '') { |
| 379 | 380 | $mode = 'insert'; |
@@ -490,7 +491,7 @@ discard block |
||
| 490 | 491 | { |
| 491 | 492 | $out = false; |
| 492 | 493 | if ($ds instanceof mysqli_result) { |
| 493 | - switch($mode){ |
|
| 494 | + switch($mode) { |
|
| 494 | 495 | case 'assoc': |
| 495 | 496 | $out = $ds->fetch_assoc(); |
| 496 | 497 | break; |
@@ -225,13 +225,13 @@ discard block |
||
| 225 | 225 | $orderBy = trim($orderBy); |
| 226 | 226 | $limit = trim($limit); |
| 227 | 227 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 228 | - $where = "WHERE {$where}"; |
|
| 228 | + $where = "where {$where}"; |
|
| 229 | 229 | } |
| 230 | 230 | if ($orderBy !== '' && stripos($orderBy, 'ORDER BY') !== 0) { |
| 231 | 231 | $orderBy = "ORDER BY {$orderBy}"; |
| 232 | 232 | } |
| 233 | 233 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 234 | - $limit = "LIMIT {$limit}"; |
|
| 234 | + $limit = "limit {$limit}"; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $out = $this->query("DELETE FROM {$from} {$where} {$orderBy} {$limit}"); |
@@ -272,16 +272,16 @@ discard block |
||
| 272 | 272 | $orderBy = trim($orderBy); |
| 273 | 273 | $limit = trim($limit); |
| 274 | 274 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 275 | - $where = "WHERE {$where}"; |
|
| 275 | + $where = "where {$where}"; |
|
| 276 | 276 | } |
| 277 | 277 | if ($orderBy !== '' && stripos($orderBy, 'ORDER') !== 0) { |
| 278 | 278 | $orderBy = "ORDER BY {$orderBy}"; |
| 279 | 279 | } |
| 280 | 280 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 281 | - $limit = "LIMIT {$limit}"; |
|
| 281 | + $limit = "limit {$limit}"; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - return $this->query("SELECT {$fields} FROM {$from} {$where} {$orderBy} {$limit}"); |
|
| 284 | + return $this->query("select {$fields} FROM {$from} {$where} {$orderBy} {$limit}"); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -349,10 +349,10 @@ discard block |
||
| 349 | 349 | $where = trim($where); |
| 350 | 350 | $limit = trim($limit); |
| 351 | 351 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
| 352 | - $where = "WHERE {$where}"; |
|
| 352 | + $where = "where {$where}"; |
|
| 353 | 353 | } |
| 354 | 354 | if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) { |
| 355 | - $limit = "LIMIT {$limit}"; |
|
| 355 | + $limit = "limit {$limit}"; |
|
| 356 | 356 | } |
| 357 | 357 | $this->query("INSERT INTO {$intotable} {$fields} SELECT {$fromfields} FROM {$fromtable} {$where} {$limit}"); |
| 358 | 358 | } |
@@ -278,8 +278,7 @@ discard block |
||
| 278 | 278 | /** |
| 279 | 279 | * Sets the width attribute of each column in the array. |
| 280 | 280 | * |
| 281 | - * @param array $value An Array of column widths in the order of the keys in the |
|
| 282 | - * source table array. |
|
| 281 | + * @param string[] $widthArray |
|
| 283 | 282 | */ |
| 284 | 283 | public function setColumnWidths($widthArray) |
| 285 | 284 | { |
@@ -289,7 +288,6 @@ discard block |
||
| 289 | 288 | /** |
| 290 | 289 | * An optional array of values that can be preselected when using |
| 291 | 290 | * |
| 292 | - * @param array $value Indicates the INPUT form element type attribute. |
|
| 293 | 291 | */ |
| 294 | 292 | public function setSelectedValues($valueArray) |
| 295 | 293 | { |
@@ -326,7 +324,7 @@ discard block |
||
| 326 | 324 | /** |
| 327 | 325 | * Determines what class the current row should have applied. |
| 328 | 326 | * |
| 329 | - * @param int $value The position of the current row being rendered. |
|
| 327 | + * @param integer $position |
|
| 330 | 328 | * @return string |
| 331 | 329 | */ |
| 332 | 330 | public function determineRowClass($position) |
@@ -353,7 +351,6 @@ discard block |
||
| 353 | 351 | * Generates an onclick action applied to the current cell, to execute |
| 354 | 352 | * any specified cell actions. |
| 355 | 353 | * |
| 356 | - * @param string $value Indicates the INPUT form element type attribute. |
|
| 357 | 354 | * @return string |
| 358 | 355 | */ |
| 359 | 356 | public function getCellAction($currentActionFieldValue) |
@@ -395,7 +392,7 @@ discard block |
||
| 395 | 392 | /** |
| 396 | 393 | * Function to prepare a link generated in the table cell/link actions. |
| 397 | 394 | * |
| 398 | - * @param string $value Indicates the INPUT form element type attribute. |
|
| 395 | + * @param string $link |
|
| 399 | 396 | * @return string |
| 400 | 397 | */ |
| 401 | 398 | public function prepareLink($link) |
@@ -414,7 +411,7 @@ discard block |
||
| 414 | 411 | * |
| 415 | 412 | * @param array $fieldsArray The associative array representing the table rows |
| 416 | 413 | * and columns. |
| 417 | - * @param array $fieldHeadersArray An optional array of values for providing |
|
| 414 | + * @param string[] $fieldHeadersArray An optional array of values for providing |
|
| 418 | 415 | * alternative field headers; this is an associative arrays of keys from |
| 419 | 416 | * the $fieldsArray where the values represent the alt heading content |
| 420 | 417 | * for each column. |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function setTableWidth($value) |
| 132 | 132 | { |
| 133 | - $this->tableWidth = (int)$value; |
|
| 133 | + $this->tableWidth = (int) $value; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | { |
| 318 | 318 | $currentWidth = ''; |
| 319 | 319 | if (is_array($this->columnWidths)) { |
| 320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
| 320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $currentClass = $this->rowAlternateClass; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return ' class="' . $currentClass . '"'; |
|
| 349 | + return ' class="'.$currentClass.'"'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | $cellAction = ''; |
| 362 | 362 | if ($this->cellAction) { |
| 363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
| 363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | $cell = $value; |
| 379 | 379 | if ($this->linkAction) { |
| 380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
| 380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $end = '?'; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - return $link . $end; |
|
| 409 | + return $link.$end; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (is_array($fieldsArray)) { |
| 427 | 427 | $i = 0; |
| 428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
| 429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
| 429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
| 430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
| 431 | 431 | if (is_array($this->selectedValues)) { |
| 432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
| 437 | 437 | $colPosition = 0; |
| 438 | 438 | foreach ($fieldValue as $key => $value) { |
| 439 | 439 | if (!in_array($key, $this->excludeFields)) { |
| 440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
| 440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
| 441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
| 442 | 442 | $table .= "</td>\n"; |
| 443 | 443 | if ($i == 0) { |
| 444 | 444 | if (empty ($header) && $this->formElementType) { |
| 445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
| 445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
| 446 | 446 | } |
| 447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
| 448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
| 448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
| 449 | 449 | } |
| 450 | 450 | $colPosition++; |
| 451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
| 453 | 453 | $i++; |
| 454 | 454 | $table .= "\t</tr>\n"; |
| 455 | 455 | } |
| 456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
| 456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
| 457 | 457 | if ($this->formElementType) { |
| 458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
| 458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
| 459 | 459 | } |
| 460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
| 461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | |
| 470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
| 471 | 471 | */ |
| 472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
| 472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
| 473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
| 474 | 474 | |
| 475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | <script language="javascript"> |
| 479 | 479 | toggled = 0; |
| 480 | 480 | function clickAll() { |
| 481 | - myform = document.getElementById("' . $this->formName . '"); |
|
| 481 | + myform = document.getElementById("' . $this->formName.'"); |
|
| 482 | 482 | for(i=0;i<myform.length;i++) { |
| 483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
| 484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | if ($this->formElementType) { |
| 492 | 492 | if ($this->extra) { |
| 493 | - $table .= "\n" . $this->extra . "\n"; |
|
| 493 | + $table .= "\n".$this->extra."\n"; |
|
| 494 | 494 | } |
| 495 | - $table .= "\n" . '</form>' . "\n"; |
|
| 495 | + $table .= "\n".'</form>'."\n"; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
| 516 | 516 | $nav = ''; |
| 517 | 517 | if ($numPages > 1) { |
| 518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
| 518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
| 519 | 519 | if ($currentPage > 6) { |
| 520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
| 521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - $this->pageNav = ' ' . $nav; |
|
| 543 | + $this->pageNav = ' '.$nav; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
| 557 | 557 | { |
| 558 | 558 | global $modx; |
| 559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
| 560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
| 559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
| 560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
| 561 | 561 | if (!empty($qs)) { |
| 562 | 562 | $qs = "?$qs"; |
| 563 | 563 | } |
| 564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
| 565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
| 566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
| 565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
| 566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
| 567 | 567 | |
| 568 | 568 | return $nav; |
| 569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $field = ''; |
| 582 | 582 | if ($this->formElementType) { |
| 583 | 583 | $checked = $isChecked ? "checked " : ""; |
| 584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
| 584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | public function handlePaging() |
| 596 | 596 | { |
| 597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
| 598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
| 598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
| 599 | 599 | |
| 600 | 600 | return $limitClause; |
| 601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | public function handleSorting($natural_order = false) |
| 611 | 611 | { |
| 612 | 612 | $orderByClause = ''; |
| 613 | - if ((bool)$natural_order === false) { |
|
| 613 | + if ((bool) $natural_order === false) { |
|
| 614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
| 615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
| 616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
| 616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
| 645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | } |
@@ -457,7 +457,8 @@ |
||
| 457 | 457 | if ($this->formElementType) { |
| 458 | 458 | $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
| 459 | 459 | } |
| 460 | - if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
|
| 460 | + if (strlen($this->pageNav) > 1) { |
|
| 461 | +//changed to display the pagination if exists. |
|
| 461 | 462 | /* commented this part because of cookie |
| 462 | 463 | $table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">'; |
| 463 | 464 | $pageSizes= array (10, 25, 50, 100, 250); |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * This function returns the current page number. |
| 151 | 151 | * |
| 152 | - * @return int |
|
| 152 | + * @return string |
|
| 153 | 153 | */ |
| 154 | 154 | public function getCurrentPage() |
| 155 | 155 | { |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | $array_paging['total'] = $this->int_nbr_row; |
| 102 | 102 | |
| 103 | 103 | if ($this->int_cur_position != 0) { |
| 104 | - $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0" . $this->str_ext_argv . "\">"; |
|
| 105 | - $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . ($this->int_cur_position - $this->int_num_result) . $this->str_ext_argv . "\">"; |
|
| 104 | + $array_paging['first_link'] = "<a href=\"$PHP_SELF?int_cur_position=0".$this->str_ext_argv."\">"; |
|
| 105 | + $array_paging['previous_link'] = "<a href=\"$PHP_SELF?int_cur_position=".($this->int_cur_position - $this->int_num_result).$this->str_ext_argv."\">"; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if (($this->int_nbr_row - $this->int_cur_position) > $this->int_num_result) { |
| 109 | 109 | $int_new_position = $this->int_cur_position + $this->int_num_result; |
| 110 | - $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=" . $this->int_nbr_row . $this->str_ext_argv . "\">"; |
|
| 111 | - $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position" . $this->str_ext_argv . "\">"; |
|
| 110 | + $array_paging['last_link'] = "<a href=\"$PHP_SELF?int_cur_position=".$this->int_nbr_row.$this->str_ext_argv."\">"; |
|
| 111 | + $array_paging['next_link'] = "<a href=\"$PHP_SELF?int_cur_position=$int_new_position".$this->str_ext_argv."\">"; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return $array_paging; |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | for ($i = 0; $i < $this->getNumberOfPage(); $i++) { |
| 127 | 127 | // if current page, do not make a link |
| 128 | 128 | if ($i == $this->getCurrentPage()) { |
| 129 | - $array_all_page[$i] = "<b>" . ($i + 1) . "</b> "; |
|
| 129 | + $array_all_page[$i] = "<b>".($i + 1)."</b> "; |
|
| 130 | 130 | } else { |
| 131 | 131 | $int_new_position = ($i * $this->int_num_result); |
| 132 | - $array_all_page[$i] = "<a href=\"" . $PHP_SELF . "?int_cur_position=$int_new_position$this->str_ext_argv\">" . ($i + 1) . "</a> "; |
|
| 132 | + $array_all_page[$i] = "<a href=\"".$PHP_SELF."?int_cur_position=$int_new_position$this->str_ext_argv\">".($i + 1)."</a> "; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | // sanitize array |
| 17 | 17 | if (!function_exists('modx_sanitize_gpc')) { |
| 18 | 18 | /** |
| 19 | - * @param array|string $values |
|
| 19 | + * @param string $values |
|
| 20 | 20 | * @param int $depth |
| 21 | 21 | * @return array|string |
| 22 | 22 | */ |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | global $sanitize_seed; |
| 14 | -$sanitize_seed = 'sanitize_seed_' . base_convert(md5(__FILE__), 16, 36); |
|
| 14 | +$sanitize_seed = 'sanitize_seed_'.base_convert(md5(__FILE__), 16, 36); |
|
| 15 | 15 | |
| 16 | 16 | // sanitize array |
| 17 | 17 | if (!function_exists('modx_sanitize_gpc')) { |
@@ -349,7 +349,7 @@ |
||
| 349 | 349 | /** |
| 350 | 350 | * returns an array if a delimiter is present. returns array is a recordset is present |
| 351 | 351 | * |
| 352 | - * @param $src |
|
| 352 | + * @param string $src |
|
| 353 | 353 | * @param string $delim |
| 354 | 354 | * @param string $type |
| 355 | 355 | * @param bool $columns |
@@ -17,324 +17,324 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
| 19 | 19 | |
| 20 | - global $modx; |
|
| 20 | + global $modx; |
|
| 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 | /** |
@@ -356,20 +356,20 @@ discard block |
||
| 356 | 356 | * @return array|string |
| 357 | 357 | */ |
| 358 | 358 | function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
| 359 | - global $modx; |
|
| 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 | - } |
|
| 359 | + global $modx; |
|
| 360 | + if($modx->db->isResult($src)) { |
|
| 361 | + // must be a recordset |
|
| 362 | + $rows = array(); |
|
| 363 | + while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | + return ($type == "array") ? $rows : implode($delim, $rows); |
|
| 365 | + } else { |
|
| 366 | + // must be a text |
|
| 367 | + if($type == "array") { |
|
| 368 | + return explode($delim, $src); |
|
| 369 | + } else { |
|
| 370 | + return $src; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -377,21 +377,21 @@ discard block |
||
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | 379 | function getUnixtimeFromDateString($value) { |
| 380 | - $timestamp = false; |
|
| 381 | - // Check for MySQL or legacy style date |
|
| 382 | - $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | - $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | - $matches = array(); |
|
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | - $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - // If those didn't work, use strtotime to figure out the date |
|
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 394 | - $timestamp = strtotime($value); |
|
| 395 | - } |
|
| 396 | - return $timestamp; |
|
| 380 | + $timestamp = false; |
|
| 381 | + // Check for MySQL or legacy style date |
|
| 382 | + $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 383 | + $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
|
| 384 | + $matches = array(); |
|
| 385 | + if(strpos($value, '-') !== false) { |
|
| 386 | + if(preg_match($date_match_1, $value, $matches)) { |
|
| 387 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
|
| 388 | + } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 389 | + $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + // If those didn't work, use strtotime to figure out the date |
|
| 393 | + if($timestamp === false || $timestamp === -1) { |
|
| 394 | + $timestamp = strtotime($value); |
|
| 395 | + } |
|
| 396 | + return $timestamp; |
|
| 397 | 397 | } |
@@ -15,38 +15,38 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
| 19 | 19 | |
| 20 | 20 | global $modx; |
| 21 | 21 | $o = ''; |
| 22 | 22 | |
| 23 | 23 | // process any TV commands in value |
| 24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
| 24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
| 25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
| 26 | 26 | |
| 27 | 27 | $params = array(); |
| 28 | - if($paramstring) { |
|
| 28 | + if ($paramstring) { |
|
| 29 | 29 | $cp = explode("&", $paramstring); |
| 30 | - foreach($cp as $p => $v) { |
|
| 30 | + foreach ($cp as $p => $v) { |
|
| 31 | 31 | $v = trim($v); // trim |
| 32 | 32 | $ar = explode("=", $v); |
| 33 | - if(is_array($ar) && count($ar) == 2) { |
|
| 33 | + if (is_array($ar) && count($ar) == 2) { |
|
| 34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $id = "tv$name"; |
| 40 | - switch($format) { |
|
| 40 | + switch ($format) { |
|
| 41 | 41 | case 'image': |
| 42 | 42 | $images = parseInput($value, '||', 'array'); |
| 43 | - foreach($images as $image) { |
|
| 44 | - if(!is_array($image)) { |
|
| 43 | + foreach ($images as $image) { |
|
| 44 | + if (!is_array($image)) { |
|
| 45 | 45 | $image = explode('==', $image); |
| 46 | 46 | } |
| 47 | 47 | $src = $image[0]; |
| 48 | 48 | |
| 49 | - if($src) { |
|
| 49 | + if ($src) { |
|
| 50 | 50 | // We have a valid source |
| 51 | 51 | $attributes = ''; |
| 52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
| 57 | 57 | 'style' => $params['style'] |
| 58 | 58 | ); |
| 59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
| 59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
| 60 | 60 | $attr['align'] = $params['align']; |
| 61 | 61 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | - $attributes .= ' ' . $params['attrib']; |
|
| 62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 63 | + $attributes .= ' '.$params['attrib']; |
|
| 64 | 64 | |
| 65 | 65 | // Output the image with attributes |
| 66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
| 66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | case "delim": // display as delimitted list |
| 72 | 72 | $value = parseInput($value, "||"); |
| 73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
| 74 | - if($p == "\\n") { |
|
| 74 | + if ($p == "\\n") { |
|
| 75 | 75 | $p = "\n"; |
| 76 | 76 | } |
| 77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | case "string": |
| 81 | 81 | $value = parseInput($value); |
| 82 | 82 | $format = strtolower($params['format']); |
| 83 | - if($format == 'upper case') { |
|
| 83 | + if ($format == 'upper case') { |
|
| 84 | 84 | $o = strtoupper($value); |
| 85 | - } else if($format == 'lower case') { |
|
| 85 | + } else if ($format == 'lower case') { |
|
| 86 | 86 | $o = strtolower($value); |
| 87 | - } else if($format == 'sentence case') { |
|
| 87 | + } else if ($format == 'sentence case') { |
|
| 88 | 88 | $o = ucfirst($value); |
| 89 | - } else if($format == 'capitalize') { |
|
| 89 | + } else if ($format == 'capitalize') { |
|
| 90 | 90 | $o = ucwords($value); |
| 91 | 91 | } else { |
| 92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | break; |
| 95 | 95 | |
| 96 | 96 | case "date": |
| 97 | - if($value != '' || $params['default'] == 'Yes') { |
|
| 98 | - if(empty($value)) { |
|
| 97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
| 98 | + if (empty($value)) { |
|
| 99 | 99 | $value = 'now'; |
| 100 | 100 | } |
| 101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | $value = parseInput($value, "||", "array"); |
| 111 | 111 | $o = ''; |
| 112 | 112 | $countValue = count($value); |
| 113 | - for($i = 0; $i < $countValue; $i++) { |
|
| 113 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
| 115 | - if(!$url) { |
|
| 115 | + if (!$url) { |
|
| 116 | 116 | $url = $name; |
| 117 | 117 | } |
| 118 | - if($url) { |
|
| 119 | - if($o) { |
|
| 118 | + if ($url) { |
|
| 119 | + if ($o) { |
|
| 120 | 120 | $o .= '<br />'; |
| 121 | 121 | } |
| 122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | 'style' => $params['style'], |
| 129 | 129 | 'target' => $params['target'], |
| 130 | 130 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 133 | 133 | |
| 134 | 134 | // Output the link |
| 135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
| 135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | $o = ''; |
| 145 | 145 | // Loop through a list of tags |
| 146 | 146 | $countValue = count($value); |
| 147 | - for($i = 0; $i < $countValue; $i++) { |
|
| 147 | + for ($i = 0; $i < $countValue; $i++) { |
|
| 148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
| 149 | - if(!$tagvalue) { |
|
| 149 | + if (!$tagvalue) { |
|
| 150 | 150 | continue; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | 'class' => $params['class'], |
| 158 | 158 | 'style' => $params['style'], |
| 159 | 159 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
| 160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
| 161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
| 162 | 162 | |
| 163 | 163 | // Output the HTML Tag |
| 164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
| 164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
| 171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
| 172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
| 173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
| 173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
| 174 | 174 | $o .= $modx->htmlspecialchars($value); |
| 175 | 175 | $o .= '</textarea></div>'; |
| 176 | 176 | $replace_richtext = array($id); |
| 177 | 177 | // setup editors |
| 178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
| 179 | 179 | // invoke OnRichTextEditorInit event |
| 180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
| 181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | 'width' => $w, |
| 185 | 185 | 'height' => $h |
| 186 | 186 | )); |
| 187 | - if(is_array($evtOut)) { |
|
| 187 | + if (is_array($evtOut)) { |
|
| 188 | 188 | $o .= implode("", $evtOut); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | case "viewport": |
| 199 | 199 | $value = parseInput($value); |
| 200 | - $id = '_' . time(); |
|
| 201 | - if(!$params['vpid']) { |
|
| 200 | + $id = '_'.time(); |
|
| 201 | + if (!$params['vpid']) { |
|
| 202 | 202 | $params['vpid'] = $id; |
| 203 | 203 | } |
| 204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
| 206 | 206 | $autoMode = "0"; |
| 207 | 207 | $w = $params['width']; |
| 208 | 208 | $h = $params['height']; |
| 209 | - if($params['stretch'] == 'Yes') { |
|
| 209 | + if ($params['stretch'] == 'Yes') { |
|
| 210 | 210 | $w = "100%"; |
| 211 | 211 | $h = "100%"; |
| 212 | 212 | } |
| 213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | - $autoMode = "3"; //both |
|
| 215 | - } else if($params['awidth'] == 'Yes') { |
|
| 213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
| 214 | + $autoMode = "3"; //both |
|
| 215 | + } else if ($params['awidth'] == 'Yes') { |
|
| 216 | 216 | $autoMode = "1"; //width only |
| 217 | - } else if($params['aheight'] == 'Yes') { |
|
| 218 | - $autoMode = "2"; //height only |
|
| 217 | + } else if ($params['aheight'] == 'Yes') { |
|
| 218 | + $autoMode = "2"; //height only |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
| 221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
| 222 | 222 | 'name' => 'viewport', |
| 223 | 223 | 'version' => '0', |
| 224 | 224 | 'plaintext' => false |
| 225 | 225 | )); |
| 226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
| 227 | - if($params['class']) { |
|
| 228 | - $o .= " class='" . $params['class'] . "' "; |
|
| 226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
| 227 | + if ($params['class']) { |
|
| 228 | + $o .= " class='".$params['class']."' "; |
|
| 229 | 229 | } |
| 230 | - if($params['style']) { |
|
| 231 | - $o .= " style='" . $params['style'] . "' "; |
|
| 230 | + if ($params['style']) { |
|
| 231 | + $o .= " style='".$params['style']."' "; |
|
| 232 | 232 | } |
| 233 | - if($params['attrib']) { |
|
| 234 | - $o .= $params['attrib'] . " "; |
|
| 233 | + if ($params['attrib']) { |
|
| 234 | + $o .= $params['attrib']." "; |
|
| 235 | 235 | } |
| 236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
| 237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
| 238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
| 236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
| 237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
| 238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
| 239 | 239 | $o .= ">"; |
| 240 | 240 | $o .= $eTag; |
| 241 | 241 | break; |
| 242 | 242 | |
| 243 | 243 | case "datagrid": |
| 244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
| 244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
| 245 | 245 | $grd = new DataGrid('', $value); |
| 246 | 246 | |
| 247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | case 'htmlentities': |
| 278 | 278 | $value = parseInput($value); |
| 279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
| 281 | 281 | $value = str_replace('||', '', $value); |
| 282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
| 287 | 287 | $widget_output = ''; |
| 288 | 288 | $o = ''; |
| 289 | 289 | /* If we are loading a file */ |
| 290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
| 292 | - if(!file_exists($file_name)) { |
|
| 293 | - $widget_output = $file_name . ' does not exist'; |
|
| 290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
| 291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
| 292 | + if (!file_exists($file_name)) { |
|
| 293 | + $widget_output = $file_name.' does not exist'; |
|
| 294 | 294 | } else { |
| 295 | 295 | $widget_output = file_get_contents($file_name); |
| 296 | 296 | } |
| 297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
| 299 | - if(!file_exists($file_name)) { |
|
| 300 | - $widget_output = $file_name . ' does not exist'; |
|
| 297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
| 298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
| 299 | + if (!file_exists($file_name)) { |
|
| 300 | + $widget_output = $file_name.' does not exist'; |
|
| 301 | 301 | } else { |
| 302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
| 303 | 303 | include $file_name; |
| 304 | 304 | } |
| 305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
| 306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
| 307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
| 308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
| 309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
| 310 | 310 | $widget_output = eval($eval_str); |
| 311 | - } elseif($value !== '') { |
|
| 311 | + } elseif ($value !== '') { |
|
| 312 | 312 | $widget_output = $params['output']; |
| 313 | 313 | } else { |
| 314 | 314 | $widget_output = ''; |
| 315 | 315 | } |
| 316 | - if(is_string($widget_output)) { |
|
| 316 | + if (is_string($widget_output)) { |
|
| 317 | 317 | $_ = $modx->config['enable_filter']; |
| 318 | 318 | $modx->config['enable_filter'] = 1; |
| 319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | default: |
| 328 | 328 | $value = parseInput($value); |
| 329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
| 330 | 330 | // add separator |
| 331 | 331 | $value = explode('||', $value); |
| 332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param string $s |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 344 | +function decodeParamValue($s){ |
|
| 345 | 345 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 346 | return str_replace("%26", '&', $s); // & |
| 347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | * @param bool $columns |
| 356 | 356 | * @return array|string |
| 357 | 357 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
| 359 | 359 | global $modx; |
| 360 | - if($modx->db->isResult($src)) { |
|
| 360 | + if ($modx->db->isResult($src)) { |
|
| 361 | 361 | // must be a recordset |
| 362 | 362 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 365 | } else { |
| 366 | 366 | // must be a text |
| 367 | - if($type == "array") { |
|
| 367 | + if ($type == "array") { |
|
| 368 | 368 | return explode($delim, $src); |
| 369 | 369 | } else { |
| 370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
| 376 | 376 | * @param string $value |
| 377 | 377 | * @return bool|false|int |
| 378 | 378 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 379 | +function getUnixtimeFromDateString($value){ |
|
| 380 | 380 | $timestamp = false; |
| 381 | 381 | // Check for MySQL or legacy style date |
| 382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
| 384 | 384 | $matches = array(); |
| 385 | - if(strpos($value, '-') !== false) { |
|
| 386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
| 385 | + if (strpos($value, '-') !== false) { |
|
| 386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
| 387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
| 388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
| 388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
| 389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | // If those didn't work, use strtotime to figure out the date |
| 393 | - if($timestamp === false || $timestamp === -1) { |
|
| 393 | + if ($timestamp === false || $timestamp === -1) { |
|
| 394 | 394 | $timestamp = strtotime($value); |
| 395 | 395 | } |
| 396 | 396 | return $timestamp; |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | * @param string $sep |
| 16 | 16 | * @return mixed|string |
| 17 | 17 | */ |
| 18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
| 18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | global $modx; |
| 21 | 22 | $o = ''; |
@@ -59,7 +60,9 @@ discard block |
||
| 59 | 60 | if(isset($params['align']) && $params['align'] != 'none') { |
| 60 | 61 | $attr['align'] = $params['align']; |
| 61 | 62 | } |
| 62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 63 | + foreach($attr as $k => $v) { |
|
| 64 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 65 | + } |
|
| 63 | 66 | $attributes .= ' ' . $params['attrib']; |
| 64 | 67 | |
| 65 | 68 | // Output the image with attributes |
@@ -128,7 +131,9 @@ discard block |
||
| 128 | 131 | 'style' => $params['style'], |
| 129 | 132 | 'target' => $params['target'], |
| 130 | 133 | ); |
| 131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 134 | + foreach($attr as $k => $v) { |
|
| 135 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 136 | + } |
|
| 132 | 137 | $attributes .= ' ' . $params['attrib']; // add extra |
| 133 | 138 | |
| 134 | 139 | // Output the link |
@@ -157,7 +162,9 @@ discard block |
||
| 157 | 162 | 'class' => $params['class'], |
| 158 | 163 | 'style' => $params['style'], |
| 159 | 164 | ); |
| 160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 165 | + foreach($attr as $k => $v) { |
|
| 166 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
| 167 | + } |
|
| 161 | 168 | $attributes .= ' ' . $params['attrib']; // add extra |
| 162 | 169 | |
| 163 | 170 | // Output the HTML Tag |
@@ -341,7 +348,8 @@ discard block |
||
| 341 | 348 | * @param string $s |
| 342 | 349 | * @return string |
| 343 | 350 | */ |
| 344 | -function decodeParamValue($s) { |
|
| 351 | +function decodeParamValue($s) |
|
| 352 | +{ |
|
| 345 | 353 | $s = str_replace("%3D", '=', $s); // = |
| 346 | 354 | return str_replace("%26", '&', $s); // & |
| 347 | 355 | } |
@@ -355,12 +363,16 @@ discard block |
||
| 355 | 363 | * @param bool $columns |
| 356 | 364 | * @return array|string |
| 357 | 365 | */ |
| 358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
| 366 | +function parseInput($src, $delim = "||", $type = "string", $columns = true) |
|
| 367 | +{ |
|
| 368 | +// type can be: string, array |
|
| 359 | 369 | global $modx; |
| 360 | 370 | if($modx->db->isResult($src)) { |
| 361 | 371 | // must be a recordset |
| 362 | 372 | $rows = array(); |
| 363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 373 | + while($cols = $modx->db->getRow($src, 'num')) { |
|
| 374 | + $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
| 375 | + } |
|
| 364 | 376 | return ($type == "array") ? $rows : implode($delim, $rows); |
| 365 | 377 | } else { |
| 366 | 378 | // must be a text |
@@ -376,7 +388,8 @@ discard block |
||
| 376 | 388 | * @param string $value |
| 377 | 389 | * @return bool|false|int |
| 378 | 390 | */ |
| 379 | -function getUnixtimeFromDateString($value) { |
|
| 391 | +function getUnixtimeFromDateString($value) |
|
| 392 | +{ |
|
| 380 | 393 | $timestamp = false; |
| 381 | 394 | // Check for MySQL or legacy style date |
| 382 | 395 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |