@@ -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( |
@@ -23,7 +23,9 @@ |
||
23 | 23 | * DO NOT CHANGE |
24 | 24 | */ |
25 | 25 | |
26 | -if (!defined('INSIDE')) die(); |
|
26 | +if (!defined('INSIDE')) { |
|
27 | + die(); |
|
28 | +} |
|
27 | 29 | |
28 | 30 | $a_lang_array = (array( |
29 | 31 | // Metamatter |
@@ -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( |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | // Вытаскиваем корневой элемент |
110 | 110 | $root = $this->__get(reset($offset)); |
111 | 111 | $current_leaf = &$root; |
112 | - while(($leaf_index = next($offset)) !== false) { |
|
112 | + while (($leaf_index = next($offset)) !== false) { |
|
113 | 113 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
114 | 114 | $current_leaf = &$current_leaf[$leaf_index]; |
115 | 115 | } |
116 | - if($current_leaf != $value) { |
|
116 | + if ($current_leaf != $value) { |
|
117 | 117 | $current_leaf = $value; |
118 | 118 | // Сохраняем данные с корня |
119 | 119 | $this->__set(reset($offset), $root); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // Пакетная запись из массива ключ -> значение |
123 | 123 | !is_array($offset) ? $offset = array($offset => $value) : false; |
124 | 124 | |
125 | - foreach($offset as $key => $value) { |
|
125 | + foreach ($offset as $key => $value) { |
|
126 | 126 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
127 | 127 | } |
128 | 128 | } |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function offsetUnset($offset) { |
145 | 145 | // Если нет никакого индекса - значит нечего записывать |
146 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
146 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | 150 | !is_array($offset) ? $offset = array($offset) : false; |
151 | 151 | |
152 | - if($this->offsetExists($offset)) { |
|
152 | + if ($this->offsetExists($offset)) { |
|
153 | 153 | // Перематываем массив в конец |
154 | 154 | $key_to_delete = end($offset); |
155 | 155 | $parent_offset = $offset; |
156 | 156 | array_pop($parent_offset); |
157 | - if(!count($parent_offset)) { |
|
157 | + if (!count($parent_offset)) { |
|
158 | 158 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
159 | 159 | $this->__unset($key_to_delete); |
160 | 160 | } else { |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | |
31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
32 | 32 | |
33 | - if($this->connected) { |
|
33 | + if ($this->connected) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again'); |
39 | 39 | } |
40 | 40 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return mysqli_real_escape_string($this->link, $unescaped_string); |
91 | 91 | } |
92 | 92 | function mysql_close_link() { |
93 | - if(is_object($this->link)) { |
|
93 | + if (is_object($this->link)) { |
|
94 | 94 | $this->link->close(); |
95 | 95 | $this->connected = false; |
96 | 96 | unset($this->link); |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | $gc = $this; |
53 | 53 | |
54 | 54 | // Default db |
55 | - $gc->db = function (GlobalContainer $c) { |
|
55 | + $gc->db = function(GlobalContainer $c) { |
|
56 | 56 | classSupernova::$db = new \db_mysql($c); |
57 | 57 | |
58 | 58 | return classSupernova::$db; |
59 | 59 | }; |
60 | 60 | |
61 | - $gc->debug = function (GlobalContainer $c) { |
|
61 | + $gc->debug = function(GlobalContainer $c) { |
|
62 | 62 | return new \debug(); |
63 | 63 | }; |
64 | 64 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | // return new \Common\Types(); |
67 | 67 | // }; |
68 | 68 | // |
69 | - $gc->cache = function ($c) { |
|
69 | + $gc->cache = function($c) { |
|
70 | 70 | return new \classCache(classSupernova::$cache_prefix); |
71 | 71 | }; |
72 | 72 | |
73 | - $gc->config = function ($c) { |
|
73 | + $gc->config = function($c) { |
|
74 | 74 | return new \classConfig(classSupernova::$cache_prefix); |
75 | 75 | }; |
76 | 76 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
30 | 30 | |
31 | 31 | // Alliance bonus calculations |
32 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
32 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
33 | 33 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
34 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
34 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
35 | 35 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
36 | 36 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
37 | 37 | |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | 'deuterium_basic_income' => 0, |
68 | 68 | 'eco_scale_storage' => 1, |
69 | 69 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
70 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
70 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
71 | 71 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
72 | 72 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
73 | 73 | 'energy_basic_income' => 0, |
74 | 74 | |
75 | 75 | // Bashing protection settings |
76 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
77 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
78 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
79 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
80 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
76 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
77 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
78 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
79 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
80 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
81 | 81 | |
82 | 82 | 'Fleet_Cdr' => 30, |
83 | 83 | 'fleet_speed' => 1, |
84 | 84 | |
85 | 85 | 'fleet_update_interval' => 4, |
86 | 86 | |
87 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
88 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
87 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
88 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
89 | 89 | // Defaults |
90 | 90 | 'game_default_language' => 'ru', |
91 | 91 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | 'game_maxSystem' => 199, |
100 | 100 | 'game_maxPlanet' => 15, |
101 | 101 | // Game global settings |
102 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
102 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
103 | 103 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
104 | 104 | |
105 | 105 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
106 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
106 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
107 | 107 | // Noob protection |
108 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
108 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
109 | 109 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
110 | 110 | |
111 | 111 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | 'payment_currency_exchange_wmu' => 30, |
155 | 155 | 'payment_currency_exchange_wmz' => 1, |
156 | 156 | |
157 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
158 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
157 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
158 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
159 | 159 | |
160 | 160 | 'planet_teleport_cost' => 50000, // |
161 | 161 | 'planet_teleport_timeout' => 86400, // |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'resource_multiplier' => 1, |
174 | 174 | |
175 | 175 | //Roleplay system |
176 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
176 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
177 | 177 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
178 | 178 | |
179 | 179 | // Black Market - General |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') { |
262 | - if(!isset(self::$cacheObject)) { |
|
262 | + if (!isset(self::$cacheObject)) { |
|
263 | 263 | $className = get_class(); |
264 | 264 | self::$cacheObject = new $className($gamePrefix, $table_name); |
265 | 265 | } |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Инфа об устройстве и браузере - общая для всех |
90 | 90 | sn_db_transaction_start(); |
91 | 91 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
92 | - if($this->device_cypher) { |
|
92 | + if ($this->device_cypher) { |
|
93 | 93 | $cypher_safe = db_escape($this->device_cypher); |
94 | 94 | $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
95 | - if(!empty($device_id['device_id'])) { |
|
95 | + if (!empty($device_id['device_id'])) { |
|
96 | 96 | $this->device_id = $device_id['device_id']; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if($this->device_id <= 0) { |
|
100 | + if ($this->device_id <= 0) { |
|
101 | 101 | do { |
102 | 102 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
103 | 103 | $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $config, $sys_stop_log_hit, $is_watching; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | // $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");"); |
184 | 184 | doquery( |
185 | 185 | "INSERT INTO {{counter}} SET |
186 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
186 | + `visit_time` = '" . SN_TIME_SQL . "', |
|
187 | 187 | `user_id` = {$user_id_safe}, |
188 | 188 | `device_id` = {$this->device_id}, |
189 | 189 | `browser_id` = {$this->browser_id}, |
190 | 190 | `user_ip` = {$this->ip_v4_int}, |
191 | 191 | `user_proxy` = '{$proxy_safe}', |
192 | 192 | `page_url_id` = {$this->page_address_id}" . |
193 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
193 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') . |
|
194 | 194 | ";"); |
195 | 195 | |
196 | 196 | $is_watching = false; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Инициализация харнилища скинов |
153 | 153 | */ |
154 | 154 | protected static function init() { |
155 | - if(static::$is_init) { |
|
155 | + if (static::$is_init) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | strpos($skin_path, '/') !== false ? $skin_path = str_replace('/', '', $skin_path) : false; |
165 | 165 | |
166 | 166 | // Загружены ли уже данные по текущему скину? |
167 | - if(empty(static::$skin_list[$skin_path])) { |
|
167 | + if (empty(static::$skin_list[$skin_path])) { |
|
168 | 168 | // Прогружаем текущий скин |
169 | 169 | static::$skin_list[$skin_path] = new skin($skin_path); |
170 | 170 | static::$active = static::$skin_list[$skin_path]; |
@@ -197,22 +197,22 @@ discard block |
||
197 | 197 | |
198 | 198 | $this->is_ini_present = false; |
199 | 199 | // Проверка на корректность и существование пути |
200 | - if(is_file($this->root_physical_absolute . 'skin.ini')) { |
|
200 | + if (is_file($this->root_physical_absolute . 'skin.ini')) { |
|
201 | 201 | // Пытаемся распарсить файл |
202 | 202 | |
203 | 203 | // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать |
204 | 204 | $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini'); |
205 | - if(!empty($this->config)) { |
|
205 | + if (!empty($this->config)) { |
|
206 | 206 | |
207 | 207 | $this->is_ini_present = true; |
208 | 208 | |
209 | - if(!empty($this->config['_inherit'])) { |
|
209 | + if (!empty($this->config['_inherit'])) { |
|
210 | 210 | // Если скин наследует себя... |
211 | - if($this->config['_inherit'] == $skin_path) { |
|
211 | + if ($this->config['_inherit'] == $skin_path) { |
|
212 | 212 | // TODO - определять более сложные случаи циклических ссылок в _inherit |
213 | 213 | die('">circular skin inheritance!'); |
214 | 214 | } |
215 | - if(empty(static::$skin_list[$this->config['_inherit']])) { |
|
215 | + if (empty(static::$skin_list[$this->config['_inherit']])) { |
|
216 | 216 | static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']); |
217 | 217 | } |
218 | 218 | $this->parent = static::$skin_list[$this->config['_inherit']]; |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | } |
226 | 226 | |
227 | 227 | // Пытаемся скомпилировать _no_image заранее |
228 | - if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
228 | + if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
229 | 229 | $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]); |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Если нет заглушки |
233 | - if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
233 | + if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
234 | 234 | $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent) |
235 | 235 | // Если нет парента - берем хардкод |
236 | 236 | ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $image_tag = $this->image_tag_parse($image_tag, $template); |
261 | 261 | |
262 | 262 | // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению |
263 | - if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
263 | + if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
264 | 264 | return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]]; |
265 | 265 | } |
266 | 266 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью... |
279 | 279 | // Пытаемся вытащить путь из родителя и применить к нему свои параметры |
280 | 280 | // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку? |
281 | - if(empty($this->container[$image_id]) && !empty($this->parent)) { |
|
281 | + if (empty($this->container[$image_id]) && !empty($this->parent)) { |
|
282 | 282 | $this->container[$image_id] = $this->parent->compile_image($image_id, $template); |
283 | 283 | |
284 | 284 | // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую |
@@ -299,18 +299,18 @@ discard block |
||
299 | 299 | protected function image_tag_parse($image_tag, $template) { |
300 | 300 | $image_tag_ptl_resolved = $image_tag; |
301 | 301 | // Есть переменные из темплейта ? |
302 | - if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
302 | + if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
303 | 303 | // Что бы лишний раз не запускать регексп |
304 | 304 | // TODO - многоуровневые вложения ?! Надо ли и где их можно применить |
305 | 305 | preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches); |
306 | - foreach($matches[0] as &$match) { |
|
306 | + foreach ($matches[0] as &$match) { |
|
307 | 307 | $var_name = str_replace(array('[', ']'), '', $match); |
308 | - if(strpos($var_name, '.') !== false) { |
|
308 | + if (strpos($var_name, '.') !== false) { |
|
309 | 309 | // Вложенная переменная темплейта - на текущем уровне |
310 | 310 | // TODO Вложенная переменная из корня через "!" |
311 | 311 | list($block_name, $block_var) = explode('.', $var_name); |
312 | 312 | isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false; |
313 | - } elseif(strpos($var_name, '$') !== false) { |
|
313 | + } elseif (strpos($var_name, '$') !== false) { |
|
314 | 314 | // Корневой DEFINE |
315 | 315 | $define_name = substr($var_name, 1); |
316 | 316 | isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - if(strpos($image_tag_ptl_resolved, '|') !== false) { |
|
324 | + if (strpos($image_tag_ptl_resolved, '|') !== false) { |
|
325 | 325 | $params = explode('|', $image_tag_ptl_resolved); |
326 | 326 | $image_id = $params[0]; |
327 | 327 | unset($params[0]); |
@@ -385,11 +385,11 @@ discard block |
||
385 | 385 | $image_string = $this->container[$image_tag]; |
386 | 386 | |
387 | 387 | // Нет параметров - просто возвращаем значение по $image_name из контейнера |
388 | - if(!empty($params) && is_array($params)) { |
|
388 | + if (!empty($params) && is_array($params)) { |
|
389 | 389 | // Здесь автоматически произойдёт упорядочивание параметров |
390 | 390 | |
391 | 391 | // Параметр 'html' - выводить изображение в виде HTML-тэга |
392 | - if(in_array('html', $params)) { |
|
392 | + if (in_array('html', $params)) { |
|
393 | 393 | $image_tag = $image_tag . '|html'; |
394 | 394 | $image_string = '<img src="' . $image_string . '" />'; |
395 | 395 | $this->container[$image_tag] = $image_string; |