@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | function flt_mission_hold(&$mission_data) |
| 4 | 4 | { |
| 5 | - if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) |
|
| 5 | + if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) |
|
| 6 | 6 | { |
| 7 | 7 | fleet_send_back($mission_data['fleet']); |
| 8 | 8 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"); |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function flt_mission_hold(&$mission_data) |
|
| 4 | -{ |
|
| 3 | +function flt_mission_hold(&$mission_data) { |
|
| 5 | 4 | if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) |
| 6 | 5 | { |
| 7 | 6 | fleet_send_back($mission_data['fleet']); |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | * @copyright 2008 By Chlorel for XNova |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -function flt_mission_recycle(&$mission_data) |
|
| 11 | -{ |
|
| 10 | +function flt_mission_recycle(&$mission_data) { |
|
| 12 | 11 | $fleet_row = &$mission_data['fleet']; |
| 13 | 12 | $destination_planet = &$mission_data['dst_planet']; |
| 14 | 13 | |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | if(in_array($unit_id, sn_get_groups('flt_recyclers'))) |
| 38 | 37 | { |
| 39 | 38 | $RecyclerCapacity += $capacity; |
| 40 | - } |
|
| 41 | - else |
|
| 39 | + } else |
|
| 42 | 40 | { |
| 43 | 41 | $OtherFleetCapacity += $capacity; |
| 44 | 42 | } |
@@ -55,16 +53,14 @@ discard block |
||
| 55 | 53 | { |
| 56 | 54 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
| 57 | 55 | $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; |
| 58 | - } |
|
| 59 | - else |
|
| 56 | + } else |
|
| 60 | 57 | { |
| 61 | 58 | if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
| 62 | 59 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)) |
| 63 | 60 | { |
| 64 | 61 | $RecycledGoods["metal"] = $RecyclerCapacity / 2; |
| 65 | 62 | $RecycledGoods["crystal"] = $RecyclerCapacity / 2; |
| 66 | - } |
|
| 67 | - else |
|
| 63 | + } else |
|
| 68 | 64 | { |
| 69 | 65 | if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) |
| 70 | 66 | { |
@@ -72,20 +68,17 @@ discard block |
||
| 72 | 68 | if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $RecycledGoods["crystal"])) |
| 73 | 69 | { |
| 74 | 70 | $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"]; |
| 75 | - } |
|
| 76 | - else |
|
| 71 | + } else |
|
| 77 | 72 | { |
| 78 | 73 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
| 79 | 74 | } |
| 80 | - } |
|
| 81 | - else |
|
| 75 | + } else |
|
| 82 | 76 | { |
| 83 | 77 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
| 84 | 78 | if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $RecycledGoods["metal"])) |
| 85 | 79 | { |
| 86 | 80 | $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"]; |
| 87 | - } |
|
| 88 | - else |
|
| 81 | + } else |
|
| 89 | 82 | { |
| 90 | 83 | $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; |
| 91 | 84 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | } |
| 59 | 59 | else |
| 60 | 60 | { |
| 61 | - if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
| 61 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) and |
|
| 62 | 62 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)) |
| 63 | 63 | { |
| 64 | 64 | $RecycledGoods["metal"] = $RecyclerCapacity / 2; |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | $fleet_row = &$mission_data['fleet']; |
| 13 | 13 | $destination_planet = &$mission_data['dst_planet']; |
| 14 | 14 | |
| 15 | - if(!$fleet_row) |
|
| 15 | + if (!$fleet_row) |
|
| 16 | 16 | { |
| 17 | 17 | return CACHE_NOTHING; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if(!isset($destination_planet['id'])) |
|
| 20 | + if (!isset($destination_planet['id'])) |
|
| 21 | 21 | { |
| 22 | 22 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 23 | 23 | fleet_send_back($mission_data['fleet']); |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | $RecyclerCapacity = 0; |
| 30 | 30 | $OtherFleetCapacity = 0; |
| 31 | 31 | $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); |
| 32 | - foreach($fleet_array as $unit_id => $unit_count) |
|
| 32 | + foreach ($fleet_array as $unit_id => $unit_count) |
|
| 33 | 33 | { |
| 34 | - if(in_array($unit_id, sn_get_groups('fleet'))) |
|
| 34 | + if (in_array($unit_id, sn_get_groups('fleet'))) |
|
| 35 | 35 | { |
| 36 | 36 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; |
| 37 | - if(in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
| 37 | + if (in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
| 38 | 38 | { |
| 39 | 39 | $RecyclerCapacity += $capacity; |
| 40 | 40 | } |
@@ -46,19 +46,19 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"]; |
| 49 | - if($IncomingFleetGoods > $OtherFleetCapacity) |
|
| 49 | + if ($IncomingFleetGoods > $OtherFleetCapacity) |
|
| 50 | 50 | { |
| 51 | 51 | $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
| 54 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
| 55 | 55 | { |
| 56 | 56 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
| 57 | 57 | $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; |
| 58 | 58 | } |
| 59 | 59 | else |
| 60 | 60 | { |
| 61 | - if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
| 61 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
| 62 | 62 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)) |
| 63 | 63 | { |
| 64 | 64 | $RecycledGoods["metal"] = $RecyclerCapacity / 2; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
| 95 | + $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
| 96 | 96 | $NewCargo['Crystal'] = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"]; |
| 97 | 97 | $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"]; |
| 98 | 98 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | HelperString::numberFloorAndFormat($RecycledGoods["metal"]), $lang['Metal'], |
| 106 | 106 | HelperString::numberFloorAndFormat($RecycledGoods["crystal"]), $lang['Crystal'] |
| 107 | 107 | ); |
| 108 | - msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
| 108 | + msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
| 109 | 109 | |
| 110 | 110 | // $QryUpdateFleet = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' "; |
| 111 | 111 | // $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"; |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000; |
| 16 | 16 | $fleet_lost = array(); |
| 17 | - foreach($fleet as $unit_id => &$unit_amount) { |
|
| 17 | + foreach ($fleet as $unit_id => &$unit_amount) { |
|
| 18 | 18 | $ships_left = floor($unit_amount * $fleet_left); |
| 19 | 19 | $fleet_lost[$unit_id] = $unit_amount - $ships_left; |
| 20 | 20 | $unit_amount = $ships_left; |
| 21 | - if(!$unit_amount) { |
|
| 21 | + if (!$unit_amount) { |
|
| 22 | 22 | unset($fleet[$unit_id]); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | // $fleet = array(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));} |
|
| 34 | +function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); } |
|
| 35 | 35 | function sn_flt_mission_explore_addon(&$result) { |
| 36 | 36 | return $result; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | function flt_mission_explore(&$mission_data) { |
| 41 | - if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 41 | + if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 42 | 42 | return CACHE_NONE; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | $outcome_list = &$result['$outcome_list']; |
| 72 | 72 | $fleet_metal_points = &$result['$fleet_metal_points']; |
| 73 | 73 | |
| 74 | - if(!$ship_data) { |
|
| 75 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
| 74 | + if (!$ship_data) { |
|
| 75 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
| 76 | 76 | $unit_info = get_unit_param($unit_id); |
| 77 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 77 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
| 87 | 87 | $fleet_capacity = 0; |
| 88 | 88 | $fleet_metal_points = 0; |
| 89 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 89 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 90 | 90 | $unit_info = get_unit_param($ship_id); |
| 91 | 91 | $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY]; |
| 92 | 92 | $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1); |
| 97 | 97 | |
| 98 | 98 | $outcome_list = sn_get_groups('mission_explore_outcome_list'); |
| 99 | - $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7)); |
|
| 99 | + $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
|
| 100 | 100 | |
| 101 | 101 | $chance_max = 0; |
| 102 | - foreach($outcome_list as $key => &$value) { |
|
| 103 | - if(!$value['chance']) { |
|
| 102 | + foreach ($outcome_list as $key => &$value) { |
|
| 103 | + if (!$value['chance']) { |
|
| 104 | 104 | unset($outcome_list[$key]); |
| 105 | 105 | continue; |
| 106 | 106 | } |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | $outcome_value = mt_rand(0, $chance_max); |
| 110 | 110 | // $outcome_value = 409; |
| 111 | 111 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
| 112 | - foreach($outcome_list as $key => &$value) { |
|
| 113 | - if(!$value['chance']) { |
|
| 112 | + foreach ($outcome_list as $key => &$value) { |
|
| 113 | + if (!$value['chance']) { |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | $mission_outcome = $key; |
| 117 | 117 | $outcome_description = $value; |
| 118 | - if($outcome_value <= $outcome_description['value']) { |
|
| 118 | + if ($outcome_value <= $outcome_description['value']) { |
|
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $found_dark_matter = 0; |
| 132 | 132 | // $outcome_mission_sub = -1; |
| 133 | 133 | |
| 134 | - switch($mission_outcome) { |
|
| 134 | + switch ($mission_outcome) { |
|
| 135 | 135 | // switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG! |
| 136 | 136 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
| 137 | 137 | flt_mission_explore_outcome_lost_fleet($result); |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // Рассчитываем стоимость самого дорого корабля в металле |
| 168 | 168 | $max_metal_cost = 0; |
| 169 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 169 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 170 | 170 | $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
| 174 | 174 | $can_be_found = array(); |
| 175 | - foreach($ship_data as $ship_id => $ship_info) { |
|
| 176 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 175 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
| 176 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 177 | 177 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | unset($can_be_found[SHIP_SPY]); |
| 183 | 183 | |
| 184 | 184 | $fleet_found = array(); |
| 185 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 185 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 186 | 186 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
| 187 | 187 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
| 188 | 188 | $found_ship_cost = reset($found_ship); |
| 189 | 189 | $found_ship_id = key($found_ship); |
| 190 | 190 | |
| 191 | - if($found_ship_cost > $found_in_metal) { |
|
| 191 | + if ($found_ship_cost > $found_in_metal) { |
|
| 192 | 192 | unset($can_be_found[$found_ship_id]); |
| 193 | 193 | } else { |
| 194 | 194 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(empty($fleet_found)) { |
|
| 200 | + if (empty($fleet_found)) { |
|
| 201 | 201 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 202 | 202 | } else { |
| 203 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
| 203 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
| 204 | 204 | $fleet[$unit_id] += $unit_amount; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL]; |
| 227 | 227 | $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM]; |
| 228 | 228 | |
| 229 | - if(array_sum($resources_found) == 0) { |
|
| 229 | + if (array_sum($resources_found) == 0) { |
|
| 230 | 230 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 231 | 231 | } |
| 232 | 232 | break; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | // Рассчитываем количество найденной ТМ |
| 238 | 238 | $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
| 239 | 239 | |
| 240 | - if(!$found_dark_matter) { |
|
| 240 | + if (!$found_dark_matter) { |
|
| 241 | 241 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 242 | 242 | } |
| 243 | 243 | break; |
@@ -251,31 +251,31 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | flt_mission_explore_addon($result); |
| 253 | 253 | |
| 254 | - if($found_dark_matter) { |
|
| 254 | + if ($found_dark_matter) { |
|
| 255 | 255 | rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
| 256 | 256 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if(!empty($fleet_lost)) { |
|
| 259 | + if (!empty($fleet_lost)) { |
|
| 260 | 260 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
| 261 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
| 261 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
| 262 | 262 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $fleet_row['fleet_amount'] = array_sum($fleet); |
| 267 | - if(!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | - if(!empty($fleet_found)) { |
|
| 267 | + if (!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | + if (!empty($fleet_found)) { |
|
| 269 | 269 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
| 270 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
| 270 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
| 271 | 271 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $query_delta = array(); |
| 276 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 276 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 277 | 277 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
| 278 | - foreach($resources_found as $ship_id => $ship_amount) { |
|
| 278 | + foreach ($resources_found as $ship_id => $ship_amount) { |
|
| 279 | 279 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $query_data = array(); |
| 291 | - if(!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 291 | + if (!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 292 | 292 | $fleet_row['fleet_array'] = sys_unit_arr2str($fleet); |
| 293 | 293 | |
| 294 | 294 | // $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}"; |
@@ -316,17 +316,16 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1"); |
| 318 | 318 | |
| 319 | - if(!$msg_text) { |
|
| 319 | + if (!$msg_text) { |
|
| 320 | 320 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
| 321 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 321 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 322 | 322 | $messages = &$messages[$outcome_mission_sub]; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $msg_text = is_string($messages) ? $messages : |
|
| 326 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 325 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 327 | 326 | } |
| 328 | 327 | $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) . |
| 329 | - ($msg_text_addon ? "\r\n" . $msg_text_addon: ''); |
|
| 328 | + ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
| 330 | 329 | |
| 331 | 330 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
| 332 | 331 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $fleet_row = &$mission_data['fleet']; |
| 14 | 14 | $destination_planet = &$mission_data['dst_planet']; |
| 15 | 15 | |
| 16 | - if(!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
| 16 | + if (!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
| 17 | 17 | { |
| 18 | 18 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 19 | 19 | fleet_send_back($mission_data['fleet']); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $mission_data['src_planet']['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), |
| 27 | 27 | $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']) . |
| 28 | 28 | '<br />' . $lang['sys_relocate_mess_user']; |
| 29 | - foreach(sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
| 29 | + foreach (sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
| 30 | 30 | { |
| 31 | 31 | $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
| 32 | 32 | } |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | * @version 1.1 |
| 9 | 9 | * @copyright 2008 by Chlorel for XNova |
| 10 | 10 | */ |
| 11 | -function flt_mission_relocate($mission_data) |
|
| 12 | -{ |
|
| 11 | +function flt_mission_relocate($mission_data) { |
|
| 13 | 12 | $fleet_row = &$mission_data['fleet']; |
| 14 | 13 | $destination_planet = &$mission_data['dst_planet']; |
| 15 | 14 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | function flt_mission_destroy($mission_data) { |
| 9 | 9 | $fleet_row = $mission_data['fleet']; |
| 10 | 10 | $destination_planet = $mission_data['dst_planet']; |
| 11 | - if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
| 11 | + if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
| 12 | 12 | fleet_send_back($fleet_row); |
| 13 | 13 | |
| 14 | 14 | return CACHE_FLEET; |
@@ -170,7 +170,7 @@ |
||
| 170 | 170 | |
| 171 | 171 | function upd_db_unit_by_location($user_id = 0, $location_type, $location_id, $unit_snid = 0, $for_update = false, $fields = '*') { |
| 172 | 172 | return db_fetch(upd_do_query( |
| 173 | - "SELECT {$fields} |
|
| 173 | + "select {$fields} |
|
| 174 | 174 | FROM {{unit}} |
| 175 | 175 | WHERE |
| 176 | 176 | `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() . |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('IN_UPDATE')) { |
|
| 3 | +if (!defined('IN_UPDATE')) { |
|
| 4 | 4 | die('Trying to call update helpers externally!'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | global $update_tables; |
| 9 | 9 | |
| 10 | 10 | upd_add_more_time(); |
| 11 | - if(!$no_log) { |
|
| 11 | + if (!$no_log) { |
|
| 12 | 12 | upd_log_message("Performing query '{$query}'"); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if(strpos($query, '{{') !== false) { |
|
| 16 | - foreach($update_tables as $tableName => $cork) { |
|
| 15 | + if (strpos($query, '{{') !== false) { |
|
| 16 | + foreach ($update_tables as $tableName => $cork) { |
|
| 17 | 17 | $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | global $config, $sys_log_disabled; |
| 26 | 26 | |
| 27 | 27 | $config->db_loadItem($key); |
| 28 | - if($condition || !isset($config->$key)) { |
|
| 28 | + if ($condition || !isset($config->$key)) { |
|
| 29 | 29 | upd_add_more_time(); |
| 30 | - if(!$sys_log_disabled) { |
|
| 30 | + if (!$sys_log_disabled) { |
|
| 31 | 31 | upd_log_message("Updating config key '{$key}' with value '{$default_value}'"); |
| 32 | 32 | } |
| 33 | 33 | $config->db_saveItem($key, $default_value); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | function upd_log_message($message) { |
| 56 | 56 | global $sys_log_disabled, $upd_log, $debug; |
| 57 | 57 | |
| 58 | - if($sys_log_disabled) |
|
| 58 | + if ($sys_log_disabled) |
|
| 59 | 59 | { |
| 60 | 60 | // print("{$message}<br />"); |
| 61 | 61 | } else { |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | function upd_unset_table_info($table_name) { |
| 68 | 68 | global $update_tables, $update_indexes, $update_foreigns; |
| 69 | 69 | |
| 70 | - if(isset($update_tables[$table_name])) { |
|
| 70 | + if (isset($update_tables[$table_name])) { |
|
| 71 | 71 | unset($update_tables[$table_name]); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(isset($update_indexes[$table_name])) { |
|
| 74 | + if (isset($update_indexes[$table_name])) { |
|
| 75 | 75 | unset($update_indexes[$table_name]); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if(isset($update_foreigns[$table_name])) { |
|
| 78 | + if (isset($update_foreigns[$table_name])) { |
|
| 79 | 79 | unset($update_foreigns[$table_name]); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -89,18 +89,18 @@ discard block |
||
| 89 | 89 | upd_unset_table_info($tableName); |
| 90 | 90 | |
| 91 | 91 | $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true); |
| 92 | - while($r1 = db_fetch($q1)) { |
|
| 92 | + while ($r1 = db_fetch($q1)) { |
|
| 93 | 93 | $update_tables[$tableName][$r1['Field']] = $r1; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true); |
| 97 | - while($r1 = db_fetch($q1)) { |
|
| 97 | + while ($r1 = db_fetch($q1)) { |
|
| 98 | 98 | $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},"; |
| 99 | 99 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
| 103 | - while($r1 = db_fetch($q1)) { |
|
| 102 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
| 103 | + while ($r1 = db_fetch($q1)) { |
|
| 104 | 104 | $table_referenced = str_replace($config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
| 105 | 105 | |
| 106 | 106 | $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};"; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | function upd_alter_table($table, $alters, $condition = true) { |
| 111 | 111 | global $config, $update_tables; |
| 112 | 112 | |
| 113 | - if(!$condition) { |
|
| 113 | + if (!$condition) { |
|
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $alters_print = is_array($alters) ? dump($alters) : $alters; |
| 119 | 119 | upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); |
| 120 | 120 | |
| 121 | - if(!is_array($alters)) { |
|
| 121 | + if (!is_array($alters)) { |
|
| 122 | 122 | $alters = array($alters); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $result = upd_do_query($qry); |
| 130 | 130 | $error = db_error(); |
| 131 | - if($error) { |
|
| 131 | + if ($error) { |
|
| 132 | 132 | die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -155,19 +155,19 @@ discard block |
||
| 155 | 155 | function upd_create_table($table_name, $declaration, $tableOptions = '') { |
| 156 | 156 | global $config, $update_tables; |
| 157 | 157 | |
| 158 | - if(!$update_tables[$table_name]) { |
|
| 158 | + if (!$update_tables[$table_name]) { |
|
| 159 | 159 | upd_do_query('set foreign_key_checks = 0;', true); |
| 160 | 160 | $declaration = trim($declaration); |
| 161 | - if(substr($declaration, 0, 1) != '(') { |
|
| 161 | + if (substr($declaration, 0, 1) != '(') { |
|
| 162 | 162 | $declaration = "($declaration)"; |
| 163 | 163 | } |
| 164 | 164 | $tableOptions = trim($tableOptions); |
| 165 | - if(!empty($tableOptions)) { |
|
| 165 | + if (!empty($tableOptions)) { |
|
| 166 | 166 | $declaration .= $tableOptions; |
| 167 | 167 | } |
| 168 | 168 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}"); |
| 169 | 169 | $error = db_error(); |
| 170 | - if($error) { |
|
| 170 | + if ($error) { |
|
| 171 | 171 | die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
| 172 | 172 | } |
| 173 | 173 | upd_do_query('set foreign_key_checks = 1;', true); |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | |
| 195 | 195 | function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { |
| 196 | - if(!is_array($user)) { |
|
| 196 | + if (!is_array($user)) { |
|
| 197 | 197 | // TODO - remove later |
| 198 | 198 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
| 199 | 199 | pdump(debug_backtrace()); |
| 200 | 200 | die('USER is not ARRAY'); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if(!isset($user['id']) || !$user['id']) { |
|
| 203 | + if (!isset($user['id']) || !$user['id']) { |
|
| 204 | 204 | // TODO - remove later |
| 205 | 205 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
| 206 | 206 | pdump($user); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $db_changeset = array(); |
| 217 | 217 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
| 218 | - if($temp['unit_id']) { |
|
| 218 | + if ($temp['unit_id']) { |
|
| 219 | 219 | // update |
| 220 | 220 | $db_changeset = array( |
| 221 | 221 | 'action' => SQL_OP_UPDATE, |
@@ -261,53 +261,53 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | |
| 263 | 263 | function upd_db_changeset_apply($db_changeset) { |
| 264 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
| 264 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - foreach($db_changeset as $table_name => $table_data) { |
|
| 269 | - foreach($table_data as $record_id => $conditions) { |
|
| 268 | + foreach ($db_changeset as $table_name => $table_data) { |
|
| 269 | + foreach ($table_data as $record_id => $conditions) { |
|
| 270 | 270 | $where = ''; |
| 271 | - if(!empty($conditions['where'])) { |
|
| 271 | + if (!empty($conditions['where'])) { |
|
| 272 | 272 | $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $fields = array(); |
| 276 | - if($conditions['fields']) { |
|
| 277 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
| 276 | + if ($conditions['fields']) { |
|
| 277 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
| 278 | 278 | $condition = "`{$field_name}` = "; |
| 279 | 279 | $value = ''; |
| 280 | - if($field_data['delta']) { |
|
| 280 | + if ($field_data['delta']) { |
|
| 281 | 281 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
| 282 | - } elseif($field_data['set']) { |
|
| 283 | - $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']); |
|
| 282 | + } elseif ($field_data['set']) { |
|
| 283 | + $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
|
| 284 | 284 | } |
| 285 | - if($value) { |
|
| 285 | + if ($value) { |
|
| 286 | 286 | $fields[] = $condition . $value; |
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | $fields = implode(',', $fields); |
| 291 | 291 | |
| 292 | - switch($conditions['action']) { |
|
| 292 | + switch ($conditions['action']) { |
|
| 293 | 293 | case SQL_OP_DELETE: |
| 294 | 294 | upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); |
| 295 | 295 | break; |
| 296 | 296 | |
| 297 | 297 | case SQL_OP_UPDATE: |
| 298 | - if($fields) { |
|
| 298 | + if ($fields) { |
|
| 299 | 299 | upd_do_query("UPDATE {{{$table_name}}} SET {$fields} {$where}"); |
| 300 | 300 | } |
| 301 | 301 | break; |
| 302 | 302 | |
| 303 | 303 | case SQL_OP_INSERT: |
| 304 | - if($fields) { |
|
| 304 | + if ($fields) { |
|
| 305 | 305 | upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); |
| 306 | 306 | } |
| 307 | 307 | break; |
| 308 | 308 | |
| 309 | 309 | case SQL_OP_REPLACE: |
| 310 | - if($fields) { |
|
| 310 | + if ($fields) { |
|
| 311 | 311 | upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); |
| 312 | 312 | } |
| 313 | 313 | break; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $source_planet = &$mission_data['src_planet']; |
| 15 | 15 | $destination_planet = &$mission_data['dst_planet']; |
| 16 | 16 | |
| 17 | - if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) |
|
| 17 | + if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) |
|
| 18 | 18 | { |
| 19 | 19 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 20 | 20 | fleet_send_back($fleet_row); |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), |
| 28 | 28 | $fleet_row['fleet_resource_metal'], $lang['Metal'], |
| 29 | 29 | $fleet_row['fleet_resource_crystal'], $lang['Crystal'], |
| 30 | - $fleet_row['fleet_resource_deuterium'], $lang['Deuterium'] ); |
|
| 30 | + $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']); |
|
| 31 | 31 | msg_send_simple_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
| 32 | 32 | |
| 33 | - if($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner']) |
|
| 33 | + if ($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner']) |
|
| 34 | 34 | { |
| 35 | 35 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
| 36 | 36 | } |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | * @copyright 2008 By Chlorel for XNova |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -function flt_mission_transport(&$mission_data) |
|
| 12 | -{ |
|
| 11 | +function flt_mission_transport(&$mission_data) { |
|
| 13 | 12 | $fleet_row = &$mission_data['fleet']; |
| 14 | 13 | $source_planet = &$mission_data['src_planet']; |
| 15 | 14 | $destination_planet = &$mission_data['dst_planet']; |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | global $template; |
| 7 | 7 | |
| 8 | -if(isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) { |
|
| 8 | +if (isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) { |
|
| 9 | 9 | require_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 10 | - if($sn_page_name) { |
|
| 10 | + if ($sn_page_name) { |
|
| 11 | 11 | // Loading page-specific language files |
| 12 | 12 | |
| 13 | 13 | !empty($sn_mvc['model'][$sn_page_name]) and execute_hooks($sn_mvc['model'][$sn_page_name], $template, 'model', $sn_page_name); |
| 14 | 14 | !empty($sn_mvc['view'][$sn_page_name]) and execute_hooks($sn_mvc['view'][$sn_page_name], $template, 'view', $sn_page_name); |
| 15 | - if(!empty($template_result) && is_object($template)) { |
|
| 15 | + if (!empty($template_result) && is_object($template)) { |
|
| 16 | 16 | $template->assign_recursive($template_result); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | // Trying to load configuration from file |
| 105 | 105 | $config_exists = false; |
| 106 | 106 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
| 107 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
| 107 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
| 108 | 108 | $config_exists = true; |
| 109 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
| 109 | + } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
| 110 | 110 | $config_exists = true; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if($config_exists) { |
|
| 113 | + if ($config_exists) { |
|
| 114 | 114 | include($config_filename); |
| 115 | 115 | $module_config_array = $class_module_name . '_config'; |
| 116 | 116 | $this->config = $$module_config_array; |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | protected function __patch_menu(&$sn_menu_extra, &$menu_patch) { |
| 124 | - if(isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) { |
|
| 125 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
| 124 | + if (isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) { |
|
| 125 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
| 126 | 126 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | public function initialize() { |
| 133 | 133 | // Checking module status - is it installed and active |
| 134 | 134 | $this->check_status(); |
| 135 | - if(!$this->manifest['active']) { |
|
| 135 | + if (!$this->manifest['active']) { |
|
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Setting constants - if any |
| 140 | - if(isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) { |
|
| 141 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
| 140 | + if (isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) { |
|
| 141 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
| 142 | 142 | defined($constant_name) or define($constant_name, $constant_value); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -149,34 +149,34 @@ discard block |
||
| 149 | 149 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
| 150 | 150 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
| 151 | 151 | $this->manifest['vars'] = $this->__assign_vars(); |
| 152 | - if(!empty($this->manifest['vars'])) { |
|
| 152 | + if (!empty($this->manifest['vars'])) { |
|
| 153 | 153 | $vars_assigned = array(); |
| 154 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
| 154 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
| 155 | 155 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
| 156 | 156 | $var_name = $sub_vars[0]; |
| 157 | 157 | |
| 158 | - if(!isset($vars_assigned[$var_name])) { |
|
| 158 | + if (!isset($vars_assigned[$var_name])) { |
|
| 159 | 159 | $vars_assigned[$var_name] = true; |
| 160 | 160 | global $$var_name; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $pointer = &$$var_name; |
| 164 | - if(($n = count($sub_vars)) > 1) { |
|
| 165 | - for($i = 1; $i < $n; $i++) { |
|
| 166 | - if(defined($sub_vars[$i])) { |
|
| 164 | + if (($n = count($sub_vars)) > 1) { |
|
| 165 | + for ($i = 1; $i < $n; $i++) { |
|
| 166 | + if (defined($sub_vars[$i])) { |
|
| 167 | 167 | $sub_vars[$i] = constant($sub_vars[$i]); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
| 170 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
| 171 | 171 | $pointer[$sub_vars[$i]] = array(); |
| 172 | 172 | } |
| 173 | 173 | $pointer = &$pointer[$sub_vars[$i]]; |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if(!isset($pointer) || !is_array($pointer)) { |
|
| 177 | + if (!isset($pointer) || !is_array($pointer)) { |
|
| 178 | 178 | $pointer = $var_value; |
| 179 | - } elseif(is_array($$var_name)) { |
|
| 179 | + } elseif (is_array($$var_name)) { |
|
| 180 | 180 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -192,50 +192,50 @@ discard block |
||
| 192 | 192 | isset($this->manifest['menu_admin']) and $this->__patch_menu($sn_menu_admin_extra, $this->manifest['menu_admin']); |
| 193 | 193 | |
| 194 | 194 | global $sn_mvc; |
| 195 | - foreach($sn_mvc as $handler_type => &$handler_data) { |
|
| 195 | + foreach ($sn_mvc as $handler_type => &$handler_data) { |
|
| 196 | 196 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) { |
|
| 200 | - foreach($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) { |
|
| 201 | - foreach($i18n_file_list as &$i18n_file_data) { |
|
| 202 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
| 199 | + if (isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) { |
|
| 200 | + foreach ($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) { |
|
| 201 | + foreach ($i18n_file_list as &$i18n_file_data) { |
|
| 202 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
| 203 | 203 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | - if(!isset($sn_mvc['i18n'][$i18n_page_name])) { |
|
| 206 | + if (!isset($sn_mvc['i18n'][$i18n_page_name])) { |
|
| 207 | 207 | $sn_mvc['i18n'][$i18n_page_name] = array(); |
| 208 | 208 | } |
| 209 | 209 | $sn_mvc['i18n'][$i18n_page_name] += $i18n_file_list; |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if(!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) { |
|
| 214 | - foreach($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) { |
|
| 213 | + if (!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) { |
|
| 214 | + foreach ($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) { |
|
| 215 | 215 | !isset($sn_mvc['javascript'][$javascript_page_name]) ? $sn_mvc['javascript'][$javascript_page_name] = array() : false; |
| 216 | - foreach($javascript_list as $script_name => &$script_content) { |
|
| 216 | + foreach ($javascript_list as $script_name => &$script_content) { |
|
| 217 | 217 | $sn_mvc['javascript'][$javascript_page_name][$script_name] = $script_content; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if(!empty($this->manifest['css']) && is_array($this->manifest['css'])) { |
|
| 223 | - foreach($this->manifest['css'] as $javascript_page_name => &$javascript_list) { |
|
| 222 | + if (!empty($this->manifest['css']) && is_array($this->manifest['css'])) { |
|
| 223 | + foreach ($this->manifest['css'] as $javascript_page_name => &$javascript_list) { |
|
| 224 | 224 | !isset($sn_mvc['css'][$javascript_page_name]) ? $sn_mvc['css'][$javascript_page_name] = array() : false; |
| 225 | - foreach($javascript_list as $script_name => &$script_content) { |
|
| 225 | + foreach ($javascript_list as $script_name => &$script_content) { |
|
| 226 | 226 | $sn_mvc['css'][$javascript_page_name][$script_name] = $script_content; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if(!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) { |
|
| 232 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
| 231 | + if (!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) { |
|
| 232 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
| 233 | 233 | $sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if(!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) { |
|
| 238 | - foreach($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) { |
|
| 237 | + if (!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) { |
|
| 238 | + foreach ($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) { |
|
| 239 | 239 | $sn_mvc['navbar_main_button'][$button_image] = $button_url_relative; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | protected function __mvcRegisterPagesOld($pages) { |
| 253 | 253 | !is_array($this->manifest['mvc']['pages']) ? $this->manifest['mvc']['pages'] = array() : false; |
| 254 | - if(is_array($pages) && !empty($pages)) { |
|
| 254 | + if (is_array($pages) && !empty($pages)) { |
|
| 255 | 255 | $this->manifest['mvc']['pages'] = array_merge($this->manifest['mvc']['pages'], $pages); |
| 256 | 256 | } |
| 257 | 257 | } |