@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = array( |
@@ -419,7 +419,8 @@ discard block |
||
419 | 419 | $location_info = &static::$location_info[$location_type]; |
420 | 420 | $id_field = $location_info[P_ID]; |
421 | 421 | $table_name = $location_info[P_TABLE_NAME]; |
422 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
422 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
423 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
423 | 424 | { |
424 | 425 | if (static::$db->db_affected_rows()) { |
425 | 426 | // Обновляем данные только если ряд был затронут |
@@ -427,6 +428,7 @@ discard block |
||
427 | 428 | |
428 | 429 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
429 | 430 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
431 | + } |
|
430 | 432 | // Вытаскиваем обновленную запись |
431 | 433 | static::db_get_record_by_id($location_type, $record_id); |
432 | 434 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -460,9 +462,11 @@ discard block |
||
460 | 462 | $set = trim($set); |
461 | 463 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
462 | 464 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
463 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
465 | + if (static::$db->db_affected_rows()) { |
|
466 | + // Обновляем данные только если ряд был затронут |
|
464 | 467 | { |
465 | 468 | $record_id = db_insert_id(); |
469 | + } |
|
466 | 470 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
467 | 471 | $result = static::db_get_record_by_id($location_type, $record_id); |
468 | 472 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -483,10 +487,12 @@ discard block |
||
483 | 487 | $id_field = $location_info[P_ID]; |
484 | 488 | $table_name = $location_info[P_TABLE_NAME]; |
485 | 489 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
486 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
490 | + if (static::$db->db_affected_rows()) { |
|
491 | + // Обновляем данные только если ряд был затронут |
|
487 | 492 | { |
488 | 493 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
489 | 494 | } |
495 | + } |
|
490 | 496 | } |
491 | 497 | |
492 | 498 | return $result; |
@@ -500,11 +506,13 @@ discard block |
||
500 | 506 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
501 | 507 | |
502 | 508 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
503 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
509 | + if (static::$db->db_affected_rows()) { |
|
510 | + // Обновляем данные только если ряд был затронут |
|
504 | 511 | { |
505 | 512 | // Обнуление кэша, потому что непонятно, что поменялось |
506 | 513 | _SnCacheInternal::cache_clear($location_type); |
507 | 514 | } |
515 | + } |
|
508 | 516 | } |
509 | 517 | |
510 | 518 | return $result; |
@@ -67,8 +67,7 @@ discard block |
||
67 | 67 | ->doInsert(); |
68 | 68 | |
69 | 69 | $accept_offer = false; |
70 | - } |
|
71 | - else |
|
70 | + } else |
|
72 | 71 | { |
73 | 72 | $accept_offer = true; |
74 | 73 | $autoAccept = true; |
@@ -80,8 +79,7 @@ discard block |
||
80 | 79 | 'alliance_negotiation_relation' => $alliance_negotiation_relation, |
81 | 80 | ); |
82 | 81 | } |
83 | -} |
|
84 | -else |
|
82 | +} else |
|
85 | 83 | { |
86 | 84 | $offer_id = sys_get_param_id('offer_id'); |
87 | 85 | if($offer_id) |
@@ -92,31 +90,26 @@ discard block |
||
92 | 90 | if(!$negotiation) |
93 | 91 | { |
94 | 92 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
95 | - } |
|
96 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
93 | + } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
97 | 94 | { |
98 | 95 | // TODO: Add log of hack attempt |
99 | 96 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
100 | - } |
|
101 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
97 | + } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
102 | 98 | { |
103 | 99 | if($offer_answer == 'accept') |
104 | 100 | { |
105 | 101 | // TODO: Add log of hack attempt |
106 | 102 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
107 | - } |
|
108 | - elseif($offer_answer == 'deny') |
|
103 | + } elseif($offer_answer == 'deny') |
|
109 | 104 | { |
110 | 105 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
111 | 106 | } |
112 | - } |
|
113 | - else |
|
107 | + } else |
|
114 | 108 | { |
115 | 109 | if($offer_answer == 'accept') |
116 | 110 | { |
117 | 111 | $accept_offer = true; |
118 | - } |
|
119 | - elseif($offer_answer == 'deny') |
|
112 | + } elseif($offer_answer == 'deny') |
|
120 | 113 | { |
121 | 114 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
122 | 115 | } |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | use DBAL\OldDbChangeSet; |
8 | 8 | use Planet\DBStaticPlanet; |
9 | 9 | |
10 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
11 | -{ |
|
10 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
12 | 11 | // Here we select which part of defense should take damage: structure or shield |
13 | 12 | // $damageTo = P_SHIELD; |
14 | 13 | // $damageTo = P_STRUCTURE; |
@@ -37,8 +36,7 @@ discard block |
||
37 | 36 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
38 | 37 | $structures[$targetedStructure][0] -= $structsDestroyed; |
39 | 38 | $MIPDamage -= $structsDestroyed*$damageDone; |
40 | - } |
|
41 | - else |
|
39 | + } else |
|
42 | 40 | { |
43 | 41 | // REALLY random attack |
44 | 42 | $can_be_damaged = sn_get_groups('defense_active'); |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use Planet\DBStaticPlanet; |
5 | 5 | |
6 | -function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) |
|
7 | -{ |
|
6 | +function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) { |
|
8 | 7 | global $config, $user, $fleet_number, $lang; |
9 | 8 | |
10 | 9 | $fleet_events = array(); |
@@ -25,12 +24,10 @@ discard block |
||
25 | 24 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
26 | 25 | { |
27 | 26 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
28 | - } |
|
29 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
27 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
30 | 28 | { |
31 | 29 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
32 | - } |
|
33 | - else |
|
30 | + } else |
|
34 | 31 | { |
35 | 32 | $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
36 | 33 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -82,8 +79,7 @@ discard block |
||
82 | 79 | return $fleet_events; |
83 | 80 | } |
84 | 81 | |
85 | -function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
|
86 | -{ |
|
82 | +function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) { |
|
87 | 83 | global $user, $planetrow, $fleet_number; |
88 | 84 | |
89 | 85 | switch($fleet['ov_label'] = $ov_label) |
@@ -123,8 +119,7 @@ discard block |
||
123 | 119 | if($fleet['fleet_owner'] == $user['id']) |
124 | 120 | { |
125 | 121 | $user_data = $user; |
126 | - } |
|
127 | - else |
|
122 | + } else |
|
128 | 123 | { |
129 | 124 | $user_data = db_user_by_id($fleet['fleet_owner']); |
130 | 125 | } |
@@ -136,8 +131,7 @@ discard block |
||
136 | 131 | * @param array $planetrow |
137 | 132 | * @param template $template |
138 | 133 | */ |
139 | -function int_planet_pretemplate($planetrow, &$template) |
|
140 | -{ |
|
134 | +function int_planet_pretemplate($planetrow, &$template) { |
|
141 | 135 | global $lang, $user; |
142 | 136 | |
143 | 137 | $governor_id = $planetrow['PLANET_GOVERNOR_ID']; |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Que\DBStaticQue; |
6 | 6 | use Universe\Universe; |
7 | 7 | |
8 | -function art_use(&$user, &$planetrow, $unit_id) |
|
9 | -{ |
|
8 | +function art_use(&$user, &$planetrow, $unit_id) { |
|
10 | 9 | global $lang; |
11 | 10 | |
12 | 11 | if(!in_array($unit_id, sn_get_groups('artifacts'))) |
@@ -53,14 +52,12 @@ discard block |
||
53 | 52 | { |
54 | 53 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize, $updateDebris); |
55 | 54 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize)); |
56 | - } |
|
57 | - else |
|
55 | + } else |
|
58 | 56 | { |
59 | 57 | $message = $lang['art_lhc_moon_fail']; |
60 | 58 | } |
61 | 59 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message); |
62 | - } |
|
63 | - else |
|
60 | + } else |
|
64 | 61 | { |
65 | 62 | $message = $lang['art_moon_exists']; |
66 | 63 | } |
@@ -88,8 +85,9 @@ discard block |
||
88 | 85 | $sectors_used = 0; |
89 | 86 | foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
90 | 87 | { |
91 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
92 | - continue; |
|
88 | + if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
89 | + continue; |
|
90 | + } |
|
93 | 91 | $sectors_used += $levels_deployed; |
94 | 92 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
95 | 93 | } |
@@ -123,8 +121,7 @@ discard block |
||
123 | 121 | DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']); |
124 | 122 | $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left'])); |
125 | 123 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message); |
126 | - } |
|
127 | - else |
|
124 | + } else |
|
128 | 125 | { |
129 | 126 | $message = $lang['art_heurestic_chip_no_research']; |
130 | 127 | } |
@@ -152,8 +149,7 @@ discard block |
||
152 | 149 | $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left']) |
153 | 150 | ); |
154 | 151 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message); |
155 | - } |
|
156 | - else |
|
152 | + } else |
|
157 | 153 | { |
158 | 154 | $message = $lang['art_nano_builder_no_que']; |
159 | 155 | } |
@@ -165,8 +161,7 @@ discard block |
||
165 | 161 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
166 | 162 | OldDbChangeSet::db_changeset_apply($db_changeset); |
167 | 163 | } |
168 | - } |
|
169 | - else |
|
164 | + } else |
|
170 | 165 | { |
171 | 166 | $message = $lang['art_err_no_artifact']; |
172 | 167 | } |
@@ -32,8 +32,7 @@ |
||
32 | 32 | * @author Fabien Potencier |
33 | 33 | * @author Dominik Zogg |
34 | 34 | */ |
35 | -interface ServiceProviderInterface |
|
36 | -{ |
|
35 | +interface ServiceProviderInterface { |
|
37 | 36 | /** |
38 | 37 | * Registers services on the given container. |
39 | 38 | * |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @author Fabien Potencier |
33 | 33 | */ |
34 | -class Container implements \ArrayAccess |
|
35 | -{ |
|
34 | +class Container implements \ArrayAccess { |
|
36 | 35 | private $values = array(); |
37 | 36 | private $factories; |
38 | 37 | private $protected; |
@@ -47,8 +46,7 @@ discard block |
||
47 | 46 | * |
48 | 47 | * @param array $values The parameters or objects. |
49 | 48 | */ |
50 | - public function __construct(array $values = array()) |
|
51 | - { |
|
49 | + public function __construct(array $values = array()) { |
|
52 | 50 | $this->factories = new \SplObjectStorage(); |
53 | 51 | $this->protected = new \SplObjectStorage(); |
54 | 52 | |
@@ -71,8 +69,7 @@ discard block |
||
71 | 69 | * |
72 | 70 | * @throws \RuntimeException Prevent override of a frozen service |
73 | 71 | */ |
74 | - public function offsetSet($id, $value) |
|
75 | - { |
|
72 | + public function offsetSet($id, $value) { |
|
76 | 73 | if (isset($this->frozen[$id])) { |
77 | 74 | throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id)); |
78 | 75 | } |
@@ -90,8 +87,7 @@ discard block |
||
90 | 87 | * |
91 | 88 | * @throws \InvalidArgumentException if the identifier is not defined |
92 | 89 | */ |
93 | - public function offsetGet($id) |
|
94 | - { |
|
90 | + public function offsetGet($id) { |
|
95 | 91 | if (!isset($this->keys[$id])) { |
96 | 92 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
97 | 93 | } |
@@ -125,8 +121,7 @@ discard block |
||
125 | 121 | * |
126 | 122 | * @return bool |
127 | 123 | */ |
128 | - public function offsetExists($id) |
|
129 | - { |
|
124 | + public function offsetExists($id) { |
|
130 | 125 | return isset($this->keys[$id]); |
131 | 126 | } |
132 | 127 | |
@@ -135,8 +130,7 @@ discard block |
||
135 | 130 | * |
136 | 131 | * @param string $id The unique identifier for the parameter or object |
137 | 132 | */ |
138 | - public function offsetUnset($id) |
|
139 | - { |
|
133 | + public function offsetUnset($id) { |
|
140 | 134 | if (isset($this->keys[$id])) { |
141 | 135 | if (is_object($this->values[$id])) { |
142 | 136 | unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]); |
@@ -155,8 +149,7 @@ discard block |
||
155 | 149 | * |
156 | 150 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
157 | 151 | */ |
158 | - public function factory($callable) |
|
159 | - { |
|
152 | + public function factory($callable) { |
|
160 | 153 | if (!method_exists($callable, '__invoke')) { |
161 | 154 | throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.'); |
162 | 155 | } |
@@ -177,8 +170,7 @@ discard block |
||
177 | 170 | * |
178 | 171 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
179 | 172 | */ |
180 | - public function protect($callable) |
|
181 | - { |
|
173 | + public function protect($callable) { |
|
182 | 174 | if (!method_exists($callable, '__invoke')) { |
183 | 175 | throw new \InvalidArgumentException('Callable is not a Closure or invokable object.'); |
184 | 176 | } |
@@ -197,8 +189,7 @@ discard block |
||
197 | 189 | * |
198 | 190 | * @throws \InvalidArgumentException if the identifier is not defined |
199 | 191 | */ |
200 | - public function raw($id) |
|
201 | - { |
|
192 | + public function raw($id) { |
|
202 | 193 | if (!isset($this->keys[$id])) { |
203 | 194 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
204 | 195 | } |
@@ -223,8 +214,7 @@ discard block |
||
223 | 214 | * |
224 | 215 | * @throws \InvalidArgumentException if the identifier is not defined or not a service definition |
225 | 216 | */ |
226 | - public function extend($id, $callable) |
|
227 | - { |
|
217 | + public function extend($id, $callable) { |
|
228 | 218 | if (!isset($this->keys[$id])) { |
229 | 219 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
230 | 220 | } |
@@ -256,8 +246,7 @@ discard block |
||
256 | 246 | * |
257 | 247 | * @return array An array of value names |
258 | 248 | */ |
259 | - public function keys() |
|
260 | - { |
|
249 | + public function keys() { |
|
261 | 250 | return array_keys($this->values); |
262 | 251 | } |
263 | 252 | |
@@ -269,8 +258,7 @@ discard block |
||
269 | 258 | * |
270 | 259 | * @return static |
271 | 260 | */ |
272 | - public function register(ServiceProviderInterface $provider, array $values = array()) |
|
273 | - { |
|
261 | + public function register(ServiceProviderInterface $provider, array $values = array()) { |
|
274 | 262 | $provider->register($this); |
275 | 263 | |
276 | 264 | foreach ($values as $key => $value) { |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @package phpBB3 |
39 | 39 | */ |
40 | -class template_compile |
|
41 | -{ |
|
40 | +class template_compile { |
|
42 | 41 | var $template; |
43 | 42 | |
44 | 43 | // Various storage arrays |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | * Load template source from file |
59 | 58 | * @access private |
60 | 59 | */ |
61 | - function _tpl_load_file($handle, $store_in_db = false) |
|
62 | - { |
|
60 | + function _tpl_load_file($handle, $store_in_db = false) { |
|
63 | 61 | // Try and open template for read |
64 | 62 | if (!file_exists($this->template->files[$handle])) |
65 | 63 | { |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | { |
68 | 66 | return; |
69 | 67 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
70 | - } |
|
71 | - else |
|
68 | + } else |
|
72 | 69 | { |
73 | 70 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
74 | 71 | } |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * the ones that exist in zend_language_scanner.l |
105 | 102 | * @access private |
106 | 103 | */ |
107 | - function remove_php_tags(&$code) |
|
108 | - { |
|
104 | + function remove_php_tags(&$code) { |
|
109 | 105 | // This matches the information gathered from the internal PHP lexer |
110 | 106 | $match = array( |
111 | 107 | '#<([\?%])=?.*?\1>#s', |
@@ -120,8 +116,7 @@ discard block |
||
120 | 116 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
121 | 117 | * @access private |
122 | 118 | */ |
123 | - function compile($code, $no_echo = false, $echo_var = '') |
|
124 | - { |
|
119 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
125 | 120 | if ($echo_var) |
126 | 121 | { |
127 | 122 | global $$echo_var; |
@@ -224,15 +219,13 @@ discard block |
||
224 | 219 | $var = substr($temp, 2, -1); |
225 | 220 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
226 | 221 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
227 | - } |
|
228 | - else |
|
222 | + } else |
|
229 | 223 | { |
230 | 224 | $var = substr($temp, 1, -1); |
231 | 225 | //$file = $this->template->_rootref[$var]; |
232 | 226 | $temp = "\$this->_rootref['$var']"; |
233 | 227 | } |
234 | - } |
|
235 | - else |
|
228 | + } else |
|
236 | 229 | { |
237 | 230 | $file = $temp; |
238 | 231 | } |
@@ -291,8 +284,7 @@ discard block |
||
291 | 284 | * Compile variables |
292 | 285 | * @access private |
293 | 286 | */ |
294 | - function compile_var_tags(&$text_blocks) |
|
295 | - { |
|
287 | + function compile_var_tags(&$text_blocks) { |
|
296 | 288 | // including $lang variable |
297 | 289 | // global $lang, $config; // NOT NEDEED - $lang now is global! |
298 | 290 | |
@@ -366,8 +358,7 @@ discard block |
||
366 | 358 | * Compile blocks |
367 | 359 | * @access private |
368 | 360 | */ |
369 | - function compile_tag_block($tag_args) |
|
370 | - { |
|
361 | + function compile_tag_block($tag_args) { |
|
371 | 362 | $no_nesting = false; |
372 | 363 | |
373 | 364 | // Is the designer wanting to call another loop in a loop? |
@@ -390,8 +381,7 @@ discard block |
||
390 | 381 | if ($match[2] < 0) |
391 | 382 | { |
392 | 383 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
393 | - } |
|
394 | - else |
|
384 | + } else |
|
395 | 385 | { |
396 | 386 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
397 | 387 | } |
@@ -399,17 +389,14 @@ discard block |
||
399 | 389 | if (strlen($match[3]) < 1 || $match[3] == -1) |
400 | 390 | { |
401 | 391 | $loop_end = '$_' . $tag_args . '_count'; |
402 | - } |
|
403 | - else if ($match[3] >= 0) |
|
392 | + } else if ($match[3] >= 0) |
|
404 | 393 | { |
405 | 394 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
406 | - } |
|
407 | - else //if ($match[3] < -1) |
|
395 | + } else //if ($match[3] < -1) |
|
408 | 396 | { |
409 | 397 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
410 | 398 | } |
411 | - } |
|
412 | - else |
|
399 | + } else |
|
413 | 400 | { |
414 | 401 | $loop_start = 0; |
415 | 402 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -422,8 +409,7 @@ discard block |
||
422 | 409 | { |
423 | 410 | // We need to implode $no_nesting times from the end... |
424 | 411 | $block = array_slice($this->block_names, -$no_nesting); |
425 | - } |
|
426 | - else |
|
412 | + } else |
|
427 | 413 | { |
428 | 414 | $block = $this->block_names; |
429 | 415 | } |
@@ -433,8 +419,7 @@ discard block |
||
433 | 419 | // Block is not nested. |
434 | 420 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
435 | 421 | $varref = "\$this->_tpldata['$tag_args']"; |
436 | - } |
|
437 | - else |
|
422 | + } else |
|
438 | 423 | { |
439 | 424 | // This block is nested. |
440 | 425 | // Generate a namespace string for this block. |
@@ -473,8 +458,7 @@ discard block |
||
473 | 458 | * some adaptions for our block level methods |
474 | 459 | * @access private |
475 | 460 | */ |
476 | - function compile_tag_if($tag_args, $elseif) |
|
477 | - { |
|
461 | + function compile_tag_if($tag_args, $elseif) { |
|
478 | 462 | // Tokenize args for 'if' tag. |
479 | 463 | preg_match_all('/(?: |
480 | 464 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -582,8 +566,7 @@ discard block |
||
582 | 566 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
583 | 567 | { |
584 | 568 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
585 | - } |
|
586 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
569 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
587 | 570 | { |
588 | 571 | // Allow checking if loops are set with .loopname |
589 | 572 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -599,8 +582,7 @@ discard block |
||
599 | 582 | |
600 | 583 | // Add the block reference for the last child. |
601 | 584 | $varref .= "['" . $block . "']"; |
602 | - } |
|
603 | - else |
|
585 | + } else |
|
604 | 586 | { |
605 | 587 | $varref = '$this->_tpldata'; |
606 | 588 | |
@@ -608,8 +590,7 @@ discard block |
||
608 | 590 | $varref .= "['" . $blocks[0] . "']"; |
609 | 591 | } |
610 | 592 | $token = "sizeof($varref)"; |
611 | - } |
|
612 | - else if (!empty($token)) |
|
593 | + } else if (!empty($token)) |
|
613 | 594 | { |
614 | 595 | $token = '(' . $token . ')'; |
615 | 596 | } |
@@ -630,8 +611,7 @@ discard block |
||
630 | 611 | * Compile DEFINE tags |
631 | 612 | * @access private |
632 | 613 | */ |
633 | - function compile_tag_define($tag_args, $op) |
|
634 | - { |
|
614 | + function compile_tag_define($tag_args, $op) { |
|
635 | 615 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
636 | 616 | |
637 | 617 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -654,8 +634,7 @@ discard block |
||
654 | 634 | |
655 | 635 | // Now replace the php code |
656 | 636 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
657 | - } |
|
658 | - else |
|
637 | + } else |
|
659 | 638 | { |
660 | 639 | preg_match('#true|false|\.#i', $match[4], $type); |
661 | 640 | |
@@ -683,8 +662,7 @@ discard block |
||
683 | 662 | * Compile INCLUDE tag |
684 | 663 | * @access private |
685 | 664 | */ |
686 | - function compile_tag_include($tag_args) |
|
687 | - { |
|
665 | + function compile_tag_include($tag_args) { |
|
688 | 666 | // Process dynamic includes |
689 | 667 | if ($tag_args[0] == '$') |
690 | 668 | { |
@@ -698,8 +676,7 @@ discard block |
||
698 | 676 | * Compile INCLUDE_PHP tag |
699 | 677 | * @access private |
700 | 678 | */ |
701 | - function compile_tag_include_php($tag_args) |
|
702 | - { |
|
679 | + function compile_tag_include_php($tag_args) { |
|
703 | 680 | return "\$this->_php_include('$tag_args');"; |
704 | 681 | } |
705 | 682 | |
@@ -708,8 +685,7 @@ discard block |
||
708 | 685 | * This is from Smarty |
709 | 686 | * @access private |
710 | 687 | */ |
711 | - function _parse_is_expr($is_arg, $tokens) |
|
712 | - { |
|
688 | + function _parse_is_expr($is_arg, $tokens) { |
|
713 | 689 | $expr_end = 0; |
714 | 690 | $negate_expr = false; |
715 | 691 | |
@@ -717,8 +693,7 @@ discard block |
||
717 | 693 | { |
718 | 694 | $negate_expr = true; |
719 | 695 | $expr_type = array_shift($tokens); |
720 | - } |
|
721 | - else |
|
696 | + } else |
|
722 | 697 | { |
723 | 698 | $expr_type = $first_token; |
724 | 699 | } |
@@ -731,8 +706,7 @@ discard block |
||
731 | 706 | $expr_end++; |
732 | 707 | $expr_arg = $tokens[$expr_end++]; |
733 | 708 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
734 | - } |
|
735 | - else |
|
709 | + } else |
|
736 | 710 | { |
737 | 711 | $expr = "!($is_arg & 1)"; |
738 | 712 | } |
@@ -744,8 +718,7 @@ discard block |
||
744 | 718 | $expr_end++; |
745 | 719 | $expr_arg = $tokens[$expr_end++]; |
746 | 720 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
747 | - } |
|
748 | - else |
|
721 | + } else |
|
749 | 722 | { |
750 | 723 | $expr = "($is_arg & 1)"; |
751 | 724 | } |
@@ -784,8 +757,7 @@ discard block |
||
784 | 757 | * |
785 | 758 | * @return string |
786 | 759 | */ |
787 | - private function generate_block_varref($namespace, $varname, $defop = false) |
|
788 | - { |
|
760 | + private function generate_block_varref($namespace, $varname, $defop = false) { |
|
789 | 761 | // Strip the trailing period. |
790 | 762 | $namespace = substr($namespace, 0, -1); |
791 | 763 | |
@@ -808,8 +780,7 @@ discard block |
||
808 | 780 | * NOTE: does not expect a trailing "." on the blockname. |
809 | 781 | * @access private |
810 | 782 | */ |
811 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
812 | - { |
|
783 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
813 | 784 | // Get an array of the blocks involved. |
814 | 785 | $blocks = explode('.', $blockname); |
815 | 786 | $blockcount = sizeof($blocks) - 1; |
@@ -831,12 +802,10 @@ discard block |
||
831 | 802 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
832 | 803 | } |
833 | 804 | return $varref; |
834 | - } |
|
835 | - else if ($include_last_iterator) |
|
805 | + } else if ($include_last_iterator) |
|
836 | 806 | { |
837 | 807 | return '$_'. $blocks[$blockcount] . '_val'; |
838 | - } |
|
839 | - else |
|
808 | + } else |
|
840 | 809 | { |
841 | 810 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
842 | 811 | } |
@@ -846,8 +815,7 @@ discard block |
||
846 | 815 | * Write compiled file to cache directory |
847 | 816 | * @access private |
848 | 817 | */ |
849 | - function compile_write($handle, $data) |
|
850 | - { |
|
818 | + function compile_write($handle, $data) { |
|
851 | 819 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
852 | 820 | |
853 | 821 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -871,8 +839,7 @@ discard block |
||
871 | 839 | * Minifies template w/i PHP code by removing extra spaces |
872 | 840 | * @access private |
873 | 841 | */ |
874 | - function minify($html) |
|
875 | - { |
|
842 | + function minify($html) { |
|
876 | 843 | if(!SN::$config->tpl_minifier) |
877 | 844 | { |
878 | 845 | return $html; |