Completed
Push — work-fleets ( 3604bd...203362 )
by SuperNova.WS
06:25
created
classes/DBStatic/DBStaticPlanet.php 2 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -21,11 +21,19 @@  discard block
 block discarded – undo
21 21
     return empty($result) ? null : $result;
22 22
   }
23 23
 
24
+  /**
25
+   * @param integer $galaxy
26
+   * @param integer $system
27
+   * @param integer $planet
28
+   */
24 29
   public static function db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
25 30
     return classSupernova::db_get_record_list(LOC_PLANET,
26 31
       "{{planets}}.`galaxy` = {$galaxy} AND {{planets}}.`system` = {$system} AND {{planets}}.`planet` = {$planet} AND {{planets}}.`planet_type` = {$planet_type}", true);
27 32
   }
28 33
 
34
+  /**
35
+   * @param integer $planet_type
36
+   */
29 37
   public static function db_planet_by_gspt($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
30 38
     $galaxy = intval($galaxy);
31 39
     $system = intval($system);
@@ -120,6 +128,9 @@  discard block
 block discarded – undo
120 128
       "`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}");
121 129
   }
122 130
 
131
+  /**
132
+   * @param integer $planet_id
133
+   */
123 134
   public static function db_planet_list_by_user_or_planet($user_id, $planet_id) {
124 135
     if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
125 136
       return false;
@@ -138,6 +149,9 @@  discard block
 block discarded – undo
138 149
     return classSupernova::db_upd_record_by_id(LOC_PLANET, $planet_id, $set);
139 150
   }
140 151
 
152
+  /**
153
+   * @param integer $ui_planet_type
154
+   */
141 155
   public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) {
142 156
     if(!($set = trim($set))) {
143 157
       return false;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
     $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
69 69
     $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
70 70
     $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
71
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
72
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
71
+    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
73 72
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
74 73
 
75 74
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticUnit.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@
 block discarded – undo
118 118
     return classSupernova::$gc->cacheOperator->db_ins_record(LOC_UNIT, $set);
119 119
   }
120 120
 
121
+  /**
122
+   * @param integer $unit_location_type
123
+   */
121 124
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) {
122 125
     $where = array('unit_location_type' => $unit_location_type);
123 126
     ($unit_location_id = idval($unit_location_id)) ? $where['unit_location_id'] = $unit_location_id : false;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
210 210
     if (!empty($temp['unit_id'])) {
211
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id(
211
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id(
212 212
         LOC_UNIT,
213 213
         $temp['unit_id'],
214 214
         array(),
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
     } else {
220 220
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
221 221
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
222
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(
222
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(
223 223
         LOC_UNIT,
224 224
         array(
225 225
           'unit_player_id'     => $user['id'],
226
-          'unit_location_type' => (int)$unit_location,
226
+          'unit_location_type' => (int) $unit_location,
227 227
           'unit_location_id'   => $locationIdRendered,
228
-          'unit_type'          => (int)$unitType,
229
-          'unit_snid'          => (int)$unit_id,
230
-          'unit_level'         => (float)$unit_value,
228
+          'unit_type'          => (int) $unitType,
229
+          'unit_snid'          => (int) $unit_id,
230
+          'unit_level'         => (float) $unit_value,
231 231
         )
232 232
       );
233 233
     }
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticUser.php 1 patch
Doc Comments   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,6 +40,7 @@  discard block
 block discarded – undo
40 40
   }
41 41
 
42 42
   /**
43
+   * @param string $fields
43 44
    * @return DbResultIterator
44 45
    */
45 46
   protected static function playerSelectIterator($fields, $orderBy = '', $forUpdate = false, $groupHaving = '', $where = '', $limit = '') {
@@ -134,6 +135,9 @@  discard block
 block discarded – undo
134 135
     return $result;
135 136
   }
136 137
 
138
+  /**
139
+   * @param integer $config_user_birthday_range
140
+   */
137 141
   public static function db_user_list_to_celebrate($config_user_birthday_range) {
138 142
     $query = "SELECT
139 143
         `id`, `username`, `user_birthday`, `user_birthday_celebrated`,
@@ -213,6 +217,9 @@  discard block
 block discarded – undo
213 217
     return $user_list;
214 218
   }
215 219
 
220
+  /**
221
+   * @param string $username_unsafe
222
+   */
216 223
   public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
217 224
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
218 225
     if (!($username_unsafe = trim($username_unsafe))) {
@@ -266,7 +273,6 @@  discard block
 block discarded – undo
266 273
 
267 274
   /**
268 275
    * @param       $user_id
269
-   * @param array $set
270 276
    * @param array $adjust
271 277
    *
272 278
    * @return array|bool|mysqli_result|null
@@ -283,8 +289,8 @@  discard block
 block discarded – undo
283 289
    *    <p>array - запись пользователя с установленным полем ['id']</p>
284 290
    * @param bool      $for_update @deprecated
285 291
    * @param string    $fields @deprecated список полей или '*'/'' для всех полей
286
-   * @param null      $player
287
-   * @param bool|null $player Признак выбора записи пользователь типа "игрок"
292
+   * @param boolean      $player
293
+   * @param boolean $player Признак выбора записи пользователь типа "игрок"
288 294
    *    <p>null - Можно выбрать запись любого типа</p>
289 295
    *    <p>true - Выбирается только запись типа "игрок"</p>
290 296
    *    <p>false - Выбирается только запись типа "альянс"</p>
Please login to merge, or discard this patch.
classes/debug.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -187,6 +187,9 @@
 block discarded – undo
187 187
     return $error_backtrace;
188 188
   }
189 189
 
190
+  /**
191
+   * @param string $die_message
192
+   */
190 193
   public function error_fatal($die_message, $details = 'There is a fatal error on page') {
191 194
     // TODO - Записывать детали ошибки в лог-файл
192 195
     die($die_message);
Please login to merge, or discard this patch.
Spacing   +39 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 defined('INSIDE') || die();
34 34
 
35
-if(php_sapi_name() == "cli") {
35
+if (php_sapi_name() == "cli") {
36 36
   // In cli-mode
37 37
   define('__DEBUG_CRLF', "\r\n");
38 38
   define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
   public function log_file($message, $ident_change = 0) {
53 53
     static $ident = 0;
54 54
 
55
-    if(!defined('SN_DEBUG_LOG')) {
55
+    if (!defined('SN_DEBUG_LOG')) {
56 56
       return;
57 57
     }
58 58
 
59
-    if($this->log_file_handler === null) {
59
+    if ($this->log_file_handler === null) {
60 60
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
61 61
       @fwrite($this->log_file_handler, "\r\n\r\n");
62 62
     }
63 63
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
64
-    if($this->log_file_handler) {
64
+    if ($this->log_file_handler) {
65 65
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
66 66
     }
67 67
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     $result = array();
93 93
     $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId();
94 94
     $result[] = "tID {$transaction_id}";
95
-    foreach($backtrace as $a_trace) {
96
-      if(in_array($a_trace['function'], $exclude_functions)) {
95
+    foreach ($backtrace as $a_trace) {
96
+      if (in_array($a_trace['function'], $exclude_functions)) {
97 97
         continue;
98 98
       }
99 99
       $function =
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
111 111
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
112 112
 
113
-      if(!$long_comment) {
113
+      if (!$long_comment) {
114 114
         break;
115 115
       }
116 116
     }
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
   public function dump($dump = false, $force_base = false, $deadlock = false) {
132 132
     global $user, $planetrow;
133 133
 
134
-    if($dump === false) {
134
+    if ($dump === false) {
135 135
       return;
136 136
     }
137 137
 
138 138
     $error_backtrace = array();
139 139
     $base_dump = false;
140 140
 
141
-    if($force_base === true) {
141
+    if ($force_base === true) {
142 142
       $base_dump = true;
143 143
     }
144 144
 
145
-    if($dump === true) {
145
+    if ($dump === true) {
146 146
       $base_dump = true;
147 147
     } else {
148
-      if(!is_array($dump)) {
148
+      if (!is_array($dump)) {
149 149
         $dump = array('var' => $dump);
150 150
       }
151 151
 
152
-      foreach($dump as $dump_var_name => $dump_var) {
153
-        if($dump_var_name == 'base_dump') {
152
+      foreach ($dump as $dump_var_name => $dump_var) {
153
+        if ($dump_var_name == 'base_dump') {
154 154
           $base_dump = $dump_var;
155 155
         } else {
156 156
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -158,22 +158,21 @@  discard block
 block discarded – undo
158 158
       }
159 159
     }
160 160
 
161
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
161
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
162 162
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
163 163
       $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks();
164 164
       $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData();
165
-      foreach($error_backtrace['cSN_data'] as &$location) {
166
-        foreach($location as $location_id => &$location_data) {
167
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
168
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
165
+      foreach ($error_backtrace['cSN_data'] as &$location) {
166
+        foreach ($location as $location_id => &$location_data) {
167
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
169 168
         }
170 169
       }
171 170
       $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries();
172 171
     }
173 172
 
174
-    if($base_dump) {
175
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
176
-        foreach($this->log_array as $log) {
173
+    if ($base_dump) {
174
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
175
+        foreach ($this->log_array as $log) {
177 176
           $error_backtrace['queries'][] = $log;
178 177
         }
179 178
       }
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
   public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
203 202
     global $sys_stop_log_hit, $sys_log_disabled, $user;
204 203
 
205
-    if(empty(classSupernova::$db->connected)) {
204
+    if (empty(classSupernova::$db->connected)) {
206 205
       // TODO - писать ошибку в файл
207 206
       die('SQL server currently unavailable. Please contact Administration...');
208 207
     }
209 208
 
210 209
     sn_db_transaction_rollback();
211 210
 
212
-    if(classSupernova::$config->debug == 1) {
211
+    if (classSupernova::$config->debug == 1) {
213 212
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
214 213
       echo "<table>{$this->log}</table>";
215 214
     }
@@ -221,7 +220,7 @@  discard block
 block discarded – undo
221 220
 
222 221
     $userId = empty($user['id']) ? 0 : $user['id'];
223 222
 
224
-    if(!$sys_log_disabled) {
223
+    if (!$sys_log_disabled) {
225 224
       $query = "INSERT INTO `{{logs}}` SET
226 225
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
227 226
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
       ob_start();
241 240
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
242 241
 
243
-      foreach($error_backtrace as $name => $value) {
242
+      foreach ($error_backtrace as $name => $value) {
244 243
         print(__DEBUG_LINE);
245 244
         pdump($value, $name);
246 245
       }
@@ -258,7 +257,7 @@  discard block
 block discarded – undo
258 257
   public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
259 258
     global $user, $sys_log_disabled;
260 259
 
261
-    if(empty(classSupernova::$db->connected)) {
260
+    if (empty(classSupernova::$db->connected)) {
262 261
       // TODO - писать ошибку в файл
263 262
       die('SQL server currently unavailable. Please contact Administration...');
264 263
     }
@@ -267,7 +266,7 @@  discard block
 block discarded – undo
267 266
 
268 267
     $userId = empty($user['id']) ? 0 : $user['id'];
269 268
 
270
-    if(!$sys_log_disabled) {
269
+    if (!$sys_log_disabled) {
271 270
       $query = "INSERT INTO `{{logs}}` SET
272 271
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
273 272
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -285,11 +284,11 @@  discard block
 block discarded – undo
285 284
 // Dump variables nicer then var_dump()
286 285
 
287 286
 function dump($value, $varname = null, $level = 0, $dumper = '') {
288
-  if(isset($varname)) {
287
+  if (isset($varname)) {
289 288
     $varname .= " = ";
290 289
   }
291 290
 
292
-  if($level == -1) {
291
+  if ($level == -1) {
293 292
     $trans[' '] = '&there4;';
294 293
     $trans["\t"] = '&rArr;';
295 294
     $trans["\n"] = '&para;;';
@@ -298,7 +297,7 @@  discard block
 block discarded – undo
298 297
 
299 298
     return strtr(htmlspecialchars($value), $trans);
300 299
   }
301
-  if($level == 0) {
300
+  if ($level == 0) {
302 301
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
303 302
     $dumper = mt_rand(10, 99) . '|' . $varname;
304 303
   }
@@ -306,22 +305,22 @@  discard block
 block discarded – undo
306 305
   $type = gettype($value);
307 306
   $dumper .= $type;
308 307
 
309
-  if($type == TYPE_STRING) {
308
+  if ($type == TYPE_STRING) {
310 309
     $dumper .= '(' . strlen($value) . ')';
311 310
     $value = dump($value, '', -1);
312
-  } elseif($type == TYPE_BOOLEAN) {
311
+  } elseif ($type == TYPE_BOOLEAN) {
313 312
     $value = ($value ? 'true' : 'false');
314
-  } elseif($type == 'object') {
313
+  } elseif ($type == 'object') {
315 314
     $props = get_class_vars(get_class($value));
316 315
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
317
-    foreach($props as $key => $val) {
316
+    foreach ($props as $key => $val) {
318 317
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
319 318
       $dumper .= dump($value->$key, '', $level + 1);
320 319
     }
321 320
     $value = '';
322
-  } elseif($type == TYPE_ARRAY) {
321
+  } elseif ($type == TYPE_ARRAY) {
323 322
     $dumper .= '(' . count($value) . ')';
324
-    foreach($value as $key => $val) {
323
+    foreach ($value as $key => $val) {
325 324
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
326 325
       $dumper .= dump($val, '', $level + 1);
327 326
     }
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 //  $backtrace = $backtrace[1];
342 341
 
343 342
   $caller = '';
344
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
343
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
345 344
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
346 345
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
347 346
       $backtrace[1]['function'] .
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
 }
369 368
 
370 369
 function pr($prePrint = false) {
371
-  if($prePrint) {
370
+  if ($prePrint) {
372 371
     print(__DEBUG_CRLF);
373 372
   }
374 373
   print(mt_rand() . __DEBUG_CRLF);
@@ -378,7 +377,7 @@  discard block
 block discarded – undo
378 377
   global $_PRINT_COUNT_VALUE;
379 378
   $_PRINT_COUNT_VALUE++;
380 379
 
381
-  if($prePrint) {
380
+  if ($prePrint) {
382 381
     print(__DEBUG_CRLF);
383 382
   }
384 383
   print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
@@ -409,7 +408,7 @@  discard block
 block discarded – undo
409 408
  */
410 409
 function pdie($message = '', $level = 0) {
411 410
   $backtrace = debug_backtrace();
412
-  for($i = 0; $i < $level; $i++) {
411
+  for ($i = 0; $i < $level; $i++) {
413 412
     array_pop($backtrace);
414 413
   }
415 414
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 
92 92
     $result = array();
93 93
     $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId();
94
-    $result[] = "tID {$transaction_id}";
94
+    $result[] = "tid {$transaction_id}";
95 95
     foreach($backtrace as $a_trace) {
96 96
       if(in_array($a_trace['function'], $exclude_functions)) {
97 97
         continue;
Please login to merge, or discard this patch.
classes/sn_module_payment.php 2 patches
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
    * Рассчёт бонуса ММ
703 703
    *
704 704
    * @param            $dark_matter
705
-   * @param bool|true  $direct
705
+   * @param boolean  $direct
706 706
    * @param bool|false $return_bonus
707 707
    *
708 708
    * @return float|int
@@ -738,6 +738,12 @@  discard block
 block discarded – undo
738 738
 
739 739
   // Дополнительная ре-трансляция адреса, если в каком-то случае платежная система ожидает нелогичный ответ
740 740
   // Пример: иксолла при неправильно заданном пользователе в ордере ожидает НЕПРАВИЛЬНЫЙ_ОРДЕР, а не НЕПРАВИЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ
741
+
742
+  /**
743
+   * @param integer $error_code
744
+   *
745
+   * @return integer|null
746
+   */
741 747
   function retranslate_error($error_code, $options = array()) {
742 748
     return isset($options['retranslate_error'][$error_code]) ? $options['retranslate_error'][$error_code] : $error_code;
743 749
   }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
   public function compile_request($request) {
449 449
     global $user;
450 450
 
451
-    if(!(classSupernova::$auth->account instanceof Account)) {
451
+    if (!(classSupernova::$auth->account instanceof Account)) {
452 452
       // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
453 453
     }
454 454
     $this->account = classSupernova::$auth->account;
@@ -469,15 +469,15 @@  discard block
 block discarded – undo
469 469
     $this->payment_currency = classSupernova::$config->payment_currency_default;
470 470
     $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency);
471 471
 
472
-    if(empty($this->payment_external_currency) && !empty($this->config['currency'])) {
472
+    if (empty($this->payment_external_currency) && !empty($this->config['currency'])) {
473 473
       $this->payment_external_currency = $this->config['currency'];
474 474
     }
475
-    if(empty($this->payment_external_currency)) {
475
+    if (empty($this->payment_external_currency)) {
476 476
       throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET);
477 477
     }
478 478
 
479 479
     $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency);
480
-    if($this->payment_external_amount < 0.01) {
480
+    if ($this->payment_external_amount < 0.01) {
481 481
       throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
482 482
     }
483 483
 
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
     $this->generate_description();
487 487
 
488 488
     $this->db_insert();
489
-    if(!$this->is_exists) {
489
+    if (!$this->is_exists) {
490 490
       throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE);
491 491
     }
492 492
   }
@@ -498,24 +498,24 @@  discard block
 block discarded – undo
498 498
    * @throws Exception
499 499
    */
500 500
   protected function payment_request_process($options = array()) {
501
-    if(!$this->manifest['active']) {
501
+    if (!$this->manifest['active']) {
502 502
       throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
503 503
     }
504 504
 
505 505
     // Если есть payment_id - загружаем под него данные
506
-    if(!empty($this->payment_params['payment_id'])) {
506
+    if (!empty($this->payment_params['payment_id'])) {
507 507
       $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
508
-      if(!$this->request_payment_id) {
508
+      if (!$this->request_payment_id) {
509 509
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
510 510
       }
511 511
 
512
-      if(!$this->db_get_by_id($this->request_payment_id)) {
512
+      if (!$this->db_get_by_id($this->request_payment_id)) {
513 513
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
514 514
       }
515 515
 
516 516
       // Проверяем - был ли этот платеж обработан?
517 517
       // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
518
-      if($this->payment_status != PAYMENT_STATUS_NONE) {
518
+      if ($this->payment_status != PAYMENT_STATUS_NONE) {
519 519
         sn_db_transaction_rollback();
520 520
         sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
521 521
         die();
@@ -525,89 +525,89 @@  discard block
 block discarded – undo
525 525
     // Пытаемся получить из запроса ИД аккаунта
526 526
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
527 527
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
528
-    if(empty($request_account_id) && !empty($this->payment_account_id)) {
528
+    if (empty($request_account_id) && !empty($this->payment_account_id)) {
529 529
       $request_account_id = $this->payment_account_id;
530 530
     }
531 531
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
532
-    if(empty($request_account_id)) {
532
+    if (empty($request_account_id)) {
533 533
       // TODO - аккаунт
534 534
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
535 535
     }
536 536
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
537
-    if(empty($this->payment_account_id)) {
537
+    if (empty($this->payment_account_id)) {
538 538
       $this->payment_account_id = $request_account_id;
539 539
     }
540 540
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
541
-    if($this->payment_account_id != $request_account_id) {
541
+    if ($this->payment_account_id != $request_account_id) {
542 542
       // TODO - Поменять сообщение об ошибке
543 543
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
544 544
     }
545 545
     // Проверяем существование аккаунта с данным ИД
546
-    if(!$this->account->db_get_by_id($this->payment_account_id)) {
546
+    if (!$this->account->db_get_by_id($this->payment_account_id)) {
547 547
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
548 548
     }
549 549
 
550 550
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
551
-    if(!empty($this->payment_params['server_id'])) {
551
+    if (!empty($this->payment_params['server_id'])) {
552 552
       $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
553
-      if(SN_ROOT_VIRTUAL != $this->request_server_id) {
553
+      if (SN_ROOT_VIRTUAL != $this->request_server_id) {
554 554
         throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
555 555
       }
556 556
     }
557 557
 
558 558
     // Сверка количества оплаченной ММ с учётом бонусов
559
-    if(!empty($this->payment_params['payment_dark_matter_gained'])) {
559
+    if (!empty($this->payment_params['payment_dark_matter_gained'])) {
560 560
       $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
561
-      if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
561
+      if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
562 562
         throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
563 563
       }
564 564
       empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
565 565
     }
566
-    if(empty($this->payment_dark_matter_paid)) {
566
+    if (empty($this->payment_dark_matter_paid)) {
567 567
       // TODO - обратный расчёт из gained
568 568
     }
569 569
 
570 570
     // Проверка наличия внешнего ИД платежа
571
-    if(!empty($this->payment_params['payment_external_id'])) {
571
+    if (!empty($this->payment_params['payment_external_id'])) {
572 572
       $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
573
-      if(empty($request_payment_external_id)) {
573
+      if (empty($request_payment_external_id)) {
574 574
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
575
-      } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
575
+      } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
576 576
         // TODO - Может быть поменять сообщение
577 577
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
578 578
       }
579 579
       $this->payment_external_id = $request_payment_external_id;
580 580
     }
581 581
     // Сверка суммы, запрошенной СН к оплате
582
-    if(!empty($this->payment_params['payment_external_money'])) {
582
+    if (!empty($this->payment_params['payment_external_money'])) {
583 583
       $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
584
-      if($request_money_out != $this->payment_external_amount && $this->is_loaded) {
584
+      if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
585 585
         throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
586 586
       }
587 587
       empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
588 588
     }
589 589
     // Заполняем поле валюты платёжной системы
590
-    if(!empty($this->payment_params['payment_external_currency'])) {
590
+    if (!empty($this->payment_params['payment_external_currency'])) {
591 591
       $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
592
-      if(empty($this->payment_external_currency)) {
592
+      if (empty($this->payment_external_currency)) {
593 593
         // TODO - поменять сообщение
594 594
         throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
595 595
       }
596 596
     }
597
-    if(empty($this->payment_external_currency)) {
597
+    if (empty($this->payment_external_currency)) {
598 598
       $this->payment_external_currency = $this->config['currency'];
599 599
     }
600 600
 
601 601
     // Заполнение внутренней суммы и валюты из внешних данных
602
-    if(empty($this->payment_currency)) {
602
+    if (empty($this->payment_currency)) {
603 603
       $this->payment_currency = classSupernova::$config->payment_currency_default;
604 604
     }
605
-    if(empty($this->payment_amount) && !empty($this->payment_external_currency)) {
605
+    if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
606 606
       $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
607 607
     }
608 608
 
609 609
     // TODO - Тестовый режим
610
-    if(!empty($this->payment_params['test'])) {
610
+    if (!empty($this->payment_params['test'])) {
611 611
       $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
612 612
     }
613 613
 
@@ -634,12 +634,12 @@  discard block
 block discarded – undo
634 634
     sn_db_transaction_start();
635 635
     try {
636 636
       $response = $this->payment_request_process();
637
-    } catch(Exception $e) {
637
+    } catch (Exception $e) {
638 638
       $response['result'] = $e->getCode();
639 639
       $response['message'] = $e->getMessage();
640 640
     }
641 641
 
642
-    if($response['result'] == SN_PAYMENT_REQUEST_OK) {
642
+    if ($response['result'] == SN_PAYMENT_REQUEST_OK) {
643 643
       sn_db_transaction_commit();
644 644
       classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT);
645 645
     } else {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     }
649 649
 
650 650
     // Переводим код результата из СН в код платежной системы
651
-    if(is_array($this->result_translations) && !empty($this->result_translations)) {
651
+    if (is_array($this->result_translations) && !empty($this->result_translations)) {
652 652
       $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR];
653 653
     }
654 654
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
     $currency_from = strtolower($currency_from);
672 672
     $currency_to = strtolower($currency_to);
673 673
 
674
-    if($currency_from != $currency_to) {
674
+    if ($currency_from != $currency_to) {
675 675
       $exchange_from = get_exchange_rate($currency_from);
676 676
       $exchange_to = get_exchange_rate($currency_to);
677 677
 
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
   public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) {
696 696
     $bonus = 0;
697 697
     $dark_matter_new = $dark_matter;
698
-    if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
699
-      if($direct) {
700
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
701
-          if($dm_for_bonus <= $dark_matter) {
698
+    if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
699
+      if ($direct) {
700
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
701
+          if ($dm_for_bonus <= $dark_matter) {
702 702
             $dark_matter_new = $dark_matter * (1 + $multiplier);
703 703
             $bonus = $multiplier;
704 704
           } else {
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
           }
707 707
         }
708 708
       } else {
709
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
709
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
710 710
           $temp = $dm_for_bonus * (1 + $multiplier);
711
-          if($dark_matter >= $temp) {
711
+          if ($dark_matter >= $temp) {
712 712
             $dark_matter_new = round($dark_matter / (1 + $multiplier));
713 713
             $bonus = $multiplier;
714 714
           } else {
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
       'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(),
762 762
     );
763 763
 
764
-    if($this->payment_id) {
764
+    if ($this->payment_id) {
765 765
       $payment['payment_id'] = $this->payment_id;
766 766
       classSupernova::$gc->db->doReplaceSet('payment', $payment);
767 767
     } else {
@@ -773,12 +773,12 @@  discard block
 block discarded – undo
773 773
 
774 774
 
775 775
   public function payment_adjust_mm_new() {
776
-    if(!$this->payment_test) {
776
+    if (!$this->payment_test) {
777 777
       // Not a test payment. Adding DM to account
778 778
       $this->account = new Account($this->db);
779 779
       $this->account->db_get_by_id($this->payment_account_id);
780 780
       $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment);
781
-      if(!$result) {
781
+      if (!$result) {
782 782
         throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
783 783
       }
784 784
     }
@@ -787,25 +787,25 @@  discard block
 block discarded – undo
787 787
   public function payment_cancel(&$payment) {
788 788
     die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}');
789 789
 
790
-    if(!isset($payment['payment_status'])) {
790
+    if (!isset($payment['payment_status'])) {
791 791
       throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND);
792 792
     }
793 793
 
794
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
795
-      $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment'];
794
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
795
+      $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment'];
796 796
 
797
-      if(!$payment['payment_test']) {
797
+      if (!$payment['payment_test']) {
798 798
         $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']);
799
-        if(!$result) {
799
+        if (!$result) {
800 800
           throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
801 801
         }
802 802
       }
803 803
       $payment['payment_status'] = PAYMENT_STATUS_CANCELED;
804 804
       db_payment_update($payment['payment_id'], $payment['payment_status'], $comment_unsafe);
805 805
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK);
806
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
806
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
807 807
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK);
808
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) {
808
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
809 809
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE);
810 810
     }
811 811
   }
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 
829 829
   protected function db_complete_payment() {
830 830
     // TODO - поле payment_processed
831
-    if($this->payment_status == PAYMENT_STATUS_NONE) {
832
-      if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
831
+    if ($this->payment_status == PAYMENT_STATUS_NONE) {
832
+      if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
833 833
         $this->payment_adjust_mm_new();
834 834
         $this->payment_status = PAYMENT_STATUS_COMPLETE;
835 835
       } else {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
   protected function db_assign_payment($payment = null) {
877 877
     $this->payment_reset();
878 878
 
879
-    if(is_array($payment) && isset($payment['payment_id'])) {
879
+    if (is_array($payment) && isset($payment['payment_id'])) {
880 880
       $this->payment_id = $payment['payment_id'];
881 881
       $this->payment_status = $payment['payment_status'];
882 882
       $this->payment_date = $payment['payment_date'];
Please login to merge, or discard this patch.
classes/SnCache.php 1 patch
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@  discard block
 block discarded – undo
121 121
     }
122 122
   }
123 123
 
124
+  /**
125
+   * @param string $filter
126
+   */
124 127
   public static function queryCacheSetByFilter($location_type, $filter, $record_id) {
125 128
     SnCache::$queries[$location_type][$filter][$record_id] = &SnCache::getDataRefByLocationAndId($location_type, $record_id);
126 129
   }
@@ -160,14 +163,23 @@  discard block
 block discarded – undo
160 163
     return true; // Не всегда - от результата
161 164
   }
162 165
 
166
+  /**
167
+   * @param integer $locationType
168
+   */
163 169
   public static function getData($locationType = LOC_NONE) {
164 170
     return $locationType == LOC_NONE ? static::$data : static::$data[$locationType];
165 171
   }
166 172
 
173
+  /**
174
+   * @param integer $locationType
175
+   */
167 176
   public static function cacheUnsetElement($locationType, $recordId) {
168 177
     static::$data[$locationType][$recordId] = null;
169 178
   }
170 179
 
180
+  /**
181
+   * @param integer $locationType
182
+   */
171 183
   public static function isArrayLocation($locationType) {
172 184
     return is_array(static::$data[$locationType]);
173 185
   }
@@ -190,6 +202,9 @@  discard block
 block discarded – undo
190 202
     }
191 203
   }
192 204
 
205
+  /**
206
+   * @param integer $unit_snid
207
+   */
193 208
   public static function getUnitLocator($location_type, $location_id, $unit_snid) {
194 209
     return $unit_snid ? static::$locator[LOC_UNIT][$location_type][$location_id][$unit_snid] : static::$locator[LOC_UNIT][$location_type][$location_id];
195 210
   }
@@ -222,14 +237,23 @@  discard block
 block discarded – undo
222 237
     return static::$locks;
223 238
   }
224 239
 
240
+  /**
241
+   * @param string $filter
242
+   */
225 243
   public static function getQueriesByLocationAndFilter($locationType, $filter) {
226 244
     return !empty(static::$queries[$locationType][$filter]) && is_array(static::$queries[$locationType][$filter]) ? static::$queries[$locationType][$filter] : array();
227 245
   }
228 246
 
247
+  /**
248
+   * @param string $filter
249
+   */
229 250
   public static function isQueryCacheByLocationAndFilterEmpty($locationType, $filter) {
230 251
     return !isset(SnCache::$queries[$locationType][$filter]) || SnCache::$queries[$locationType][$filter] === null;
231 252
   }
232 253
 
254
+  /**
255
+   * @param string $filter
256
+   */
233 257
   public static function queryCacheResetByLocationAndFilter($locationType, $filter) {
234 258
     SnCache::$queries[$locationType][$filter] = array();
235 259
   }
Please login to merge, or discard this patch.
classes/SnDbCachedOperator.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -314,6 +314,9 @@  discard block
 block discarded – undo
314 314
     return $result;
315 315
   }
316 316
 
317
+  /**
318
+   * @param integer $location_type
319
+   */
317 320
   public static function db_ins_field_set($location_type, $field_set, $serialize = false) {
318 321
     // TODO multiinsert
319 322
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false;
@@ -350,7 +353,7 @@  discard block
 block discarded – undo
350 353
   /**
351 354
    * Блокирует указанные таблицу/список таблиц
352 355
    *
353
-   * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
356
+   * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
354 357
    * <p>string - название таблицы для блокировки</p>
355 358
    * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p>
356 359
    */
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -298,9 +298,11 @@
 block discarded – undo
298 298
     $set = trim($set);
299 299
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
300 300
     if ($result = $this->db->doInsert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
301
-      if ($this->db->db_affected_rows()) // Обновляем данные только если ряд был затронут
301
+      if ($this->db->db_affected_rows()) {
302
+        // Обновляем данные только если ряд был затронут
302 303
       {
303 304
         $record_id = $this->db->db_insert_id();
305
+      }
304 306
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
305 307
         $result = $this->db_get_record_by_id($location_type, $record_id);
306 308
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
               ($filter ? ' WHERE ' . $filter : '') .
243 243
               ($fetch ? ' LIMIT 1' : ''));
244 244
           }
245
-          while($row = db_fetch($query)) {
245
+          while ($row = db_fetch($query)) {
246 246
             // Исключаем из списка родительских ИД уже заблокированные записи
247 247
             if (!$this->snCache->cache_lock_get($owner_location_type, $row['parent_id'])) {
248 248
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
           . " FOR UPDATE"
283 283
         );
284 284
       }
285
-      while($row = db_fetch($query)) {
285
+      while ($row = db_fetch($query)) {
286 286
         // Caching record in row cache
287 287
         $this->snCache->cache_set($location_type, $row);
288 288
         // Making ref to cached record in query cache
Please login to merge, or discard this patch.
classes/template.php 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -103,6 +103,7 @@
 block discarded – undo
103 103
   /**
104 104
   * Set custom template location (able to use directory outside of phpBB)
105 105
   * @access public
106
+  * @param string $template_path
106 107
   */
107 108
   function set_custom_template($template_path, $template_name, $fallback_template_path = false)
108 109
   {
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 class template
26 26
 {
27 27
   /** variable that holds all the data we'll be substituting into
28
-  * the compiled templates. Takes form:
29
-  * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
30
-  * if it's a root-level variable, it'll be like this:
31
-  * --> $this->_tpldata[.][0][varname] == value
32
-  */
28
+   * the compiled templates. Takes form:
29
+   * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
30
+   * if it's a root-level variable, it'll be like this:
31
+   * --> $this->_tpldata[.][0][varname] == value
32
+   */
33 33
   var $_tpldata = array('.' => array(0 => array()));
34 34
   var $_rootref;
35 35
 //  var $_block_counter = array();
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
   var $parsed = false;
61 61
 
62 62
   /**
63
-  * Set template location
64
-  * @access public
65
-  */
63
+   * Set template location
64
+   * @access public
65
+   */
66 66
   function set_template()
67 67
   {
68 68
     global $phpbb_root_path, $user;
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
   }
102 102
 
103 103
   /**
104
-  * Set custom template location (able to use directory outside of phpBB)
105
-  * @access public
106
-  */
104
+   * Set custom template location (able to use directory outside of phpBB)
105
+   * @access public
106
+   */
107 107
   function set_custom_template($template_path, $template_name, $fallback_template_path = false)
108 108
   {
109 109
     global $phpbb_root_path, $user;
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
   }
143 143
 
144 144
   /**
145
-  * Sets the template filenames for handles. $filename_array
146
-  * should be a hash of handle => filename pairs.
147
-  * @access public
148
-  */
145
+   * Sets the template filenames for handles. $filename_array
146
+   * should be a hash of handle => filename pairs.
147
+   * @access public
148
+   */
149 149
   function set_filenames($filename_array)
150 150
   {
151 151
     if (!is_array($filename_array))
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
   }
173 173
 
174 174
   /**
175
-  * Destroy template data set
176
-  * @access public
177
-  */
175
+   * Destroy template data set
176
+   * @access public
177
+   */
178 178
   function destroy()
179 179
   {
180 180
     $this->_tpldata = array('.' => array(0 => array()));
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
   }
183 183
 
184 184
   /**
185
-  * Reset/empty complete block
186
-  * @access public
187
-  */
185
+   * Reset/empty complete block
186
+   * @access public
187
+   */
188 188
   function destroy_block_vars($blockname)
189 189
   {
190 190
     if (strpos($blockname, '.') !== false)
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
   }
213 213
 
214 214
   /**
215
-  * Display handle
216
-  * @access public
217
-  */
215
+   * Display handle
216
+   * @access public
217
+   */
218 218
   function display($handle, $include_once = true)
219 219
   {
220 220
     global $user, $phpbb_hook, $lang, $config;
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
   }
249 249
 
250 250
   /**
251
-  * Display the handle and assign the output to a template variable or return the compiled result.
252
-  * @access public
253
-  */
251
+   * Display the handle and assign the output to a template variable or return the compiled result.
252
+   * @access public
253
+   */
254 254
   function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
255 255
   {
256 256
     ob_start();
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
   }
269 269
 
270 270
   /**
271
-  * Load a compiled template if possible, if not, recompile it
272
-  * @access private
273
-  */
271
+   * Load a compiled template if possible, if not, recompile it
272
+   * @access private
273
+   */
274 274
   function _tpl_load(&$handle)
275 275
   {
276 276
     global $user, $config;
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
   }
454 454
 
455 455
   /**
456
-  * Assign key variable pairs from an array
457
-  * @access public
458
-  */
456
+   * Assign key variable pairs from an array
457
+   * @access public
458
+   */
459 459
   function assign_vars($vararray)
460 460
   {
461 461
     foreach ($vararray as $key => $val)
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
   }
468 468
 
469 469
   /**
470
-  * Assign a single variable to a single key
471
-  * @access public
472
-  */
470
+   * Assign a single variable to a single key
471
+   * @access public
472
+   */
473 473
   function assign_var($varname, $varval)
474 474
   {
475 475
     $this->_rootref[$varname] = $varval;
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
   }
479 479
 
480 480
   /**
481
-  * Assign key variable pairs from an array to a specified block
482
-  * @access public
483
-  */
481
+   * Assign key variable pairs from an array to a specified block
482
+   * @access public
483
+   */
484 484
   function assign_block_vars($blockname, $vararray)
485 485
   {
486 486
     if (strpos($blockname, '.') !== false)
@@ -545,33 +545,33 @@  discard block
 block discarded – undo
545 545
   }
546 546
 
547 547
   /**
548
-  * Change already assigned key variable pair (one-dimensional - single loop entry)
549
-  *
550
-  * An example of how to use this function:
551
-  * {@example alter_block_array.php}
552
-  *
553
-  * @param  string  $blockname  the blockname, for example 'loop'
554
-  * @param  array $vararray the var array to insert/add or merge
555
-  * @param  mixed $key    Key to search for
556
-  *
557
-  * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
558
-  *
559
-  * int: Position [the position to change or insert at directly given]
560
-  *
561
-  * If key is false the position is set to 0
562
-  * If key is true the position is set to the last entry
563
-  *
564
-  * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
565
-  *
566
-  * If insert, the vararray is inserted at the given position (position counting from zero).
567
-  * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
568
-  *
569
-  * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
570
-  * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
571
-  *
572
-  * @return bool false on error, true on success
573
-  * @access public
574
-  */
548
+   * Change already assigned key variable pair (one-dimensional - single loop entry)
549
+   *
550
+   * An example of how to use this function:
551
+   * {@example alter_block_array.php}
552
+   *
553
+   * @param  string  $blockname  the blockname, for example 'loop'
554
+   * @param  array $vararray the var array to insert/add or merge
555
+   * @param  mixed $key    Key to search for
556
+   *
557
+   * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
558
+   *
559
+   * int: Position [the position to change or insert at directly given]
560
+   *
561
+   * If key is false the position is set to 0
562
+   * If key is true the position is set to the last entry
563
+   *
564
+   * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
565
+   *
566
+   * If insert, the vararray is inserted at the given position (position counting from zero).
567
+   * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
568
+   *
569
+   * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
570
+   * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
571
+   *
572
+   * @return bool false on error, true on success
573
+   * @access public
574
+   */
575 575
   function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
576 576
   {
577 577
     if (strpos($blockname, '.') !== false)
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
   }
656 656
 
657 657
   /**
658
-  * Include a separate template
659
-  * @access private
660
-  */
658
+   * Include a separate template
659
+   * @access private
660
+   */
661 661
   function _tpl_include($filename, $include = true)
662 662
   {
663 663
     global $lang, $config;
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
   }
687 687
 
688 688
   /**
689
-  * Include a php-file
690
-  * @access private
691
-  */
689
+   * Include a php-file
690
+   * @access private
691
+   */
692 692
   function _php_include($filename)
693 693
   {
694 694
     global $phpbb_root_path;
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
   }
706 706
 
707 707
   /**
708
-  * Assign key variable pairs from an array with block support
709
-  * @access public
710
-  */
708
+   * Assign key variable pairs from an array with block support
709
+   * @access public
710
+   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713 713
     if(isset($values['.']))
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
       // Re-position template blocks
629 629
       for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
630 630
       {
631
-        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1];
631
+        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1];
632 632
         $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i;
633 633
       }
634 634
 
@@ -710,13 +710,13 @@  discard block
 block discarded – undo
710 710
   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713
-    if(isset($values['.']))
713
+    if (isset($values['.']))
714 714
     {
715 715
       $values_extra = $values['.'];
716 716
       unset($values['.']);
717 717
     }
718 718
 
719
-    if(!$name)
719
+    if (!$name)
720 720
     {
721 721
       $this->assign_vars($values);
722 722
     }
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
       $this->assign_block_vars($name, $values);
726 726
     }
727 727
 
728
-    if(isset($values_extra))
728
+    if (isset($values_extra))
729 729
     {
730
-      foreach($values_extra as $sub_array_name => $sub_array)
730
+      foreach ($values_extra as $sub_array_name => $sub_array)
731 731
       {
732 732
         $new_name = $name . ($name ? '.' : '') . $sub_array_name;
733
-        foreach($sub_array as $sub_element)
733
+        foreach ($sub_array as $sub_element)
734 734
         {
735 735
           $this->assign_recursive($sub_element, $new_name);
736 736
         }
Please login to merge, or discard this patch.
Braces   +29 added lines, -58 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@  discard block
 block discarded – undo
16 16
 * Base Template class.
17 17
 * @package phpBB3
18 18
 */
19
-class template
20
-{
19
+class template {
21 20
   /** variable that holds all the data we'll be substituting into
22 21
   * the compiled templates. Takes form:
23 22
   * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
@@ -57,8 +56,7 @@  discard block
 block discarded – undo
57 56
   * Set template location
58 57
   * @access public
59 58
   */
60
-  public function set_template()
61
-  {
59
+  public function set_template() {
62 60
     global $phpbb_root_path, $user;
63 61
 
64 62
     if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'))
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
       {
84 82
         $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template';
85 83
       }
86
-    }
87
-    else
84
+    } else
88 85
     {
89 86
       trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR);
90 87
     }
@@ -98,8 +95,7 @@  discard block
 block discarded – undo
98 95
   * Set custom template location (able to use directory outside of phpBB)
99 96
   * @access public
100 97
   */
101
-  public function set_custom_template($template_path, $template_name, $fallback_template_path = false)
102
-  {
98
+  public function set_custom_template($template_path, $template_name, $fallback_template_path = false) {
103 99
     global $phpbb_root_path, $user;
104 100
 
105 101
     // Make sure $template_path has no ending slash
@@ -120,8 +116,7 @@  discard block
 block discarded – undo
120 116
 
121 117
       $this->inherit_root = $fallback_template_path;
122 118
       $this->orig_tpl_inherits_id = true;
123
-    }
124
-    else
119
+    } else
125 120
     {
126 121
       $this->orig_tpl_inherits_id = false;
127 122
     }
@@ -140,8 +135,7 @@  discard block
 block discarded – undo
140 135
   * should be a hash of handle => filename pairs.
141 136
   * @access public
142 137
   */
143
-  public function set_filenames($filename_array)
144
-  {
138
+  public function set_filenames($filename_array) {
145 139
     if (!is_array($filename_array))
146 140
     {
147 141
       return false;
@@ -169,8 +163,7 @@  discard block
 block discarded – undo
169 163
   * Destroy template data set
170 164
   * @access public
171 165
   */
172
-  public function destroy()
173
-  {
166
+  public function destroy() {
174 167
     $this->_tpldata = array('.' => array(0 => array()));
175 168
     $this->_rootref = &$this->_tpldata['.'][0];
176 169
   }
@@ -179,8 +172,7 @@  discard block
 block discarded – undo
179 172
   * Reset/empty complete block
180 173
   * @access public
181 174
   */
182
-  public function destroy_block_vars($blockname)
183
-  {
175
+  public function destroy_block_vars($blockname) {
184 176
     if (strpos($blockname, '.') !== false)
185 177
     {
186 178
       // Nested block.
@@ -195,8 +187,7 @@  discard block
 block discarded – undo
195 187
       }
196 188
 
197 189
       unset($str[$blocks[$blockcount]]);
198
-    }
199
-    else
190
+    } else
200 191
     {
201 192
       // Top-level block.
202 193
       unset($this->_tpldata[$blockname]);
@@ -209,8 +200,7 @@  discard block
 block discarded – undo
209 200
   * Display handle
210 201
   * @access public
211 202
   */
212
-  public function display($handle, $include_once = true)
213
-  {
203
+  public function display($handle, $include_once = true) {
214 204
     global $phpbb_hook;
215 205
 
216 206
     if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once))
@@ -232,8 +222,7 @@  discard block
 block discarded – undo
232 222
     if ($filename = $this->_tpl_load($handle))
233 223
     {
234 224
       ($include_once) ? include_once($filename) : include($filename);
235
-    }
236
-    else
225
+    } else
237 226
     {
238 227
       eval(' ?>' . $this->compiled_code[$handle] . '<?php ');
239 228
     }
@@ -245,8 +234,7 @@  discard block
 block discarded – undo
245 234
   * Display the handle and assign the output to a template variable or return the compiled result.
246 235
   * @access public
247 236
   */
248
-  public function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
249
-  {
237
+  public function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) {
250 238
     ob_start();
251 239
     $this->display($handle, $include_once);
252 240
     $contents = ob_get_clean();
@@ -265,8 +253,7 @@  discard block
 block discarded – undo
265 253
   * Load a compiled template if possible, if not, recompile it
266 254
   * @access private
267 255
   */
268
-  public function _tpl_load(&$handle)
269
-  {
256
+  public function _tpl_load(&$handle) {
270 257
     global $user;
271 258
 
272 259
     if (!isset($this->filename[$handle]))
@@ -287,8 +274,7 @@  discard block
 block discarded – undo
287 274
     if (!file_exists($filename) || @filesize($filename) === 0)
288 275
     {
289 276
       $recompile = true;
290
-    }
291
-    else if (classSupernova::$config->load_tplcompile)
277
+    } else if (classSupernova::$config->load_tplcompile)
292 278
     {
293 279
       // No way around it: we need to check inheritance here
294 280
       if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle]))
@@ -376,15 +362,13 @@  discard block
 block discarded – undo
376 362
               $this->files[$row['template_filename']] = $file;
377 363
               $this->files_inherit[$row['template_filename']] = $file;
378 364
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
379
-            }
380
-            else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
365
+            } else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
381 366
             {
382 367
               // Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that.
383 368
               $force_reload = true;
384 369
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
385 370
             }
386
-          }
387
-          else
371
+          } else
388 372
           {
389 373
             $this->files_template[$row['template_filename']] = $user->theme['template_id'];
390 374
           }
@@ -394,8 +378,7 @@  discard block
 block discarded – undo
394 378
             if ($row['template_filename'] == $this->filename[$handle])
395 379
             {
396 380
               $compile->_tpl_load_file($handle, true);
397
-            }
398
-            else
381
+            } else
399 382
             {
400 383
               $this->files[$row['template_filename']] = $file;
401 384
               $this->filename[$row['template_filename']] = $row['template_filename'];
@@ -410,8 +393,7 @@  discard block
 block discarded – undo
410 393
           {
411 394
             $this->compiled_code[$handle] = $compile->compile(trim($row['template_data']));
412 395
             $compile->compile_write($handle, $this->compiled_code[$handle]);
413
-          }
414
-          else
396
+          } else
415 397
           {
416 398
             // Only bother compiling if it doesn't already exist
417 399
             if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX))
@@ -422,8 +404,7 @@  discard block
 block discarded – undo
422 404
             }
423 405
           }
424 406
         }
425
-      }
426
-      else
407
+      } else
427 408
       {
428 409
         $file = $this->root . '/' . $row['template_filename'];
429 410
 
@@ -450,8 +431,7 @@  discard block
 block discarded – undo
450 431
   * Assign key variable pairs from an array
451 432
   * @access public
452 433
   */
453
-  public function assign_vars($vararray)
454
-  {
434
+  public function assign_vars($vararray) {
455 435
     foreach ($vararray as $key => $val)
456 436
     {
457 437
       $this->_rootref[$key] = $val;
@@ -464,8 +444,7 @@  discard block
 block discarded – undo
464 444
   * Assign a single variable to a single key
465 445
   * @access public
466 446
   */
467
-  public function assign_var($varname, $varval)
468
-  {
447
+  public function assign_var($varname, $varval) {
469 448
     $this->_rootref[$varname] = $varval;
470 449
 
471 450
     return true;
@@ -475,8 +454,7 @@  discard block
 block discarded – undo
475 454
   * Assign key variable pairs from an array to a specified block
476 455
   * @access public
477 456
   */
478
-  public function assign_block_vars($blockname, $vararray)
479
-  {
457
+  public function assign_block_vars($blockname, $vararray) {
480 458
     if (strpos($blockname, '.') !== false)
481 459
     {
482 460
       // Nested block.
@@ -511,8 +489,7 @@  discard block
 block discarded – undo
511 489
       // We're adding a new iteration to this block with the given
512 490
       // variable assignments.
513 491
       $str[$blocks[$blockcount]][] = $vararray;
514
-    }
515
-    else
492
+    } else
516 493
     {
517 494
       // Top-level block.
518 495
       $s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0;
@@ -566,8 +543,7 @@  discard block
 block discarded – undo
566 543
   * @return bool false on error, true on success
567 544
   * @access public
568 545
   */
569
-  public function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
570
-  {
546
+  public function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') {
571 547
     if (strpos($blockname, '.') !== false)
572 548
     {
573 549
       // Nested blocks are not supported
@@ -612,8 +588,7 @@  discard block
 block discarded – undo
612 588
         $key = sizeof($this->_tpldata[$blockname]);
613 589
         unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']);
614 590
         $vararray['S_LAST_ROW'] = true;
615
-      }
616
-      else if ($key === 0)
591
+      } else if ($key === 0)
617 592
       {
618 593
         unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']);
619 594
         $vararray['S_FIRST_ROW'] = true;
@@ -652,8 +627,7 @@  discard block
 block discarded – undo
652 627
   * Include a separate template
653 628
   * @access private
654 629
   */
655
-  public function _tpl_include($filename, $include = true)
656
-  {
630
+  public function _tpl_include($filename, $include = true) {
657 631
     $handle = $filename;
658 632
     $this->filename[$handle] = $filename;
659 633
     $this->files[$handle] = $this->root . '/' . $filename;
@@ -681,8 +655,7 @@  discard block
 block discarded – undo
681 655
   * Include a php-file
682 656
   * @access private
683 657
   */
684
-  public function _php_include($filename)
685
-  {
658
+  public function _php_include($filename) {
686 659
     global $phpbb_root_path;
687 660
 
688 661
     $file = $phpbb_root_path . $filename;
@@ -700,8 +673,7 @@  discard block
 block discarded – undo
700 673
   * Assign key variable pairs from an array with block support
701 674
   * @access public
702 675
   */
703
-  public function assign_recursive($values, $name = '')
704
-  {
676
+  public function assign_recursive($values, $name = '') {
705 677
     if(isset($values['.']))
706 678
     {
707 679
       $values_extra = $values['.'];
@@ -711,8 +683,7 @@  discard block
 block discarded – undo
711 683
     if(!$name)
712 684
     {
713 685
       $this->assign_vars($values);
714
-    }
715
-    else
686
+    } else
716 687
     {
717 688
       $this->assign_block_vars($name, $values);
718 689
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
       // Search array to get correct position
587 587
       list($search_key, $search_value) = @each($key);
588 588
 
589
-      $key = NULL;
589
+      $key = null;
590 590
       foreach ($this->_tpldata[$blockname] as $i => $val_ary)
591 591
       {
592 592
         if ($val_ary[$search_key] === $search_value)
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
       }
598 598
 
599 599
       // key/value pair not found
600
-      if ($key === NULL)
600
+      if ($key === null)
601 601
       {
602 602
         return false;
603 603
       }
Please login to merge, or discard this patch.
classes/template_compile.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -47,6 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
   /**
49 49
   * constuctor
50
+  * @param template $template
50 51
   */
51 52
   function template_compile(&$template)
52 53
   {
@@ -463,6 +464,7 @@  discard block
 block discarded – undo
463 464
   * Compile IF tags - much of this is from Smarty with
464 465
   * some adaptions for our block level methods
465 466
   * @access private
467
+  * @param boolean $elseif
466 468
   */
467 469
   function compile_tag_if($tag_args, $elseif)
468 470
   {
@@ -620,6 +622,7 @@  discard block
 block discarded – undo
620 622
   /**
621 623
   * Compile DEFINE tags
622 624
   * @access private
625
+  * @param boolean $op
623 626
   */
624 627
   function compile_tag_define($tag_args, $op)
625 628
   {
@@ -698,6 +701,7 @@  discard block
 block discarded – undo
698 701
   * parse expression
699 702
   * This is from Smarty
700 703
   * @access private
704
+  * @param string $is_arg
701 705
   */
702 706
   function _parse_is_expr($is_arg, $tokens)
703 707
   {
@@ -794,6 +798,8 @@  discard block
 block discarded – undo
794 798
   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
795 799
   * NOTE: does not expect a trailing "." on the blockname.
796 800
   * @access private
801
+  * @param string $blockname
802
+  * @param boolean $include_last_iterator
797 803
   */
798 804
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
799 805
   {
@@ -832,6 +838,7 @@  discard block
 block discarded – undo
832 838
   /**
833 839
   * Write compiled file to cache directory
834 840
   * @access private
841
+  * @param string $data
835 842
   */
836 843
   function compile_write($handle, $data)
837 844
   {
@@ -857,6 +864,7 @@  discard block
 block discarded – undo
857 864
   /**
858 865
   * Minifies template w/i PHP code by removing extra spaces
859 866
   * @access private
867
+  * @return string
860 868
   */
861 869
   function minify($html)
862 870
   {
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
   var $block_else_level = array();
45 45
 
46 46
   /**
47
-  * constuctor
48
-  */
47
+   * constuctor
48
+   */
49 49
   function template_compile(&$template)
50 50
   {
51 51
     $this->template = &$template;
52 52
   }
53 53
 
54 54
   /**
55
-  * Load template source from file
56
-  * @access private
57
-  */
55
+   * Load template source from file
56
+   * @access private
57
+   */
58 58
   function _tpl_load_file($handle, $store_in_db = false)
59 59
   {
60 60
     // Try and open template for read
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
   }
98 98
 
99 99
   /**
100
-  * Remove any PHP tags that do not belong, these regular expressions are derived from
101
-  * the ones that exist in zend_language_scanner.l
102
-  * @access private
103
-  */
100
+   * Remove any PHP tags that do not belong, these regular expressions are derived from
101
+   * the ones that exist in zend_language_scanner.l
102
+   * @access private
103
+   */
104 104
   function remove_php_tags(&$code)
105 105
   {
106 106
     // This matches the information gathered from the internal PHP lexer
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
   }
115 115
 
116 116
   /**
117
-  * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
118
-  * @access private
119
-  */
117
+   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
118
+   * @access private
119
+   */
120 120
   function compile($code, $no_echo = false, $echo_var = '')
121 121
   {
122 122
     if ($echo_var)
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
   }
286 286
 
287 287
   /**
288
-  * Compile variables
289
-  * @access private
290
-  */
288
+   * Compile variables
289
+   * @access private
290
+   */
291 291
   function compile_var_tags(&$text_blocks)
292 292
   {
293 293
     // change template varrefs into PHP varrefs
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
   }
348 348
 
349 349
   /**
350
-  * Compile blocks
351
-  * @access private
352
-  */
350
+   * Compile blocks
351
+   * @access private
352
+   */
353 353
   function compile_tag_block($tag_args)
354 354
   {
355 355
     $no_nesting = false;
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
     $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
436 436
 
437 437
     /**
438
-    * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
439
-    * <code>
440
-    * if (!$offset)
441
-    * {
442
-    *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
443
-    * }
444
-    * </code>
445
-    */
438
+     * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
439
+     * <code>
440
+     * if (!$offset)
441
+     * {
442
+     *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
443
+     * }
444
+     * </code>
445
+     */
446 446
 
447 447
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
448 448
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
@@ -453,10 +453,10 @@  discard block
 block discarded – undo
453 453
   }
454 454
 
455 455
   /**
456
-  * Compile IF tags - much of this is from Smarty with
457
-  * some adaptions for our block level methods
458
-  * @access private
459
-  */
456
+   * Compile IF tags - much of this is from Smarty with
457
+   * some adaptions for our block level methods
458
+   * @access private
459
+   */
460 460
   function compile_tag_if($tag_args, $elseif)
461 461
   {
462 462
     // Tokenize args for 'if' tag.
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
   }
612 612
 
613 613
   /**
614
-  * Compile DEFINE tags
615
-  * @access private
616
-  */
614
+   * Compile DEFINE tags
615
+   * @access private
616
+   */
617 617
   function compile_tag_define($tag_args, $op)
618 618
   {
619 619
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
   }
665 665
 
666 666
   /**
667
-  * Compile INCLUDE tag
668
-  * @access private
669
-  */
667
+   * Compile INCLUDE tag
668
+   * @access private
669
+   */
670 670
   function compile_tag_include($tag_args)
671 671
   {
672 672
     // Process dynamic includes
@@ -679,19 +679,19 @@  discard block
 block discarded – undo
679 679
   }
680 680
 
681 681
   /**
682
-  * Compile INCLUDE_PHP tag
683
-  * @access private
684
-  */
682
+   * Compile INCLUDE_PHP tag
683
+   * @access private
684
+   */
685 685
   function compile_tag_include_php($tag_args)
686 686
   {
687 687
     return "\$this->_php_include('$tag_args');";
688 688
   }
689 689
 
690 690
   /**
691
-  * parse expression
692
-  * This is from Smarty
693
-  * @access private
694
-  */
691
+   * parse expression
692
+   * This is from Smarty
693
+   * @access private
694
+   */
695 695
   function _parse_is_expr($is_arg, $tokens)
696 696
   {
697 697
     $expr_end = 0;
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
   }
757 757
 
758 758
   /**
759
-  * Generates a reference to the given variable inside the given (possibly nested)
760
-  * block namespace. This is a string of the form:
761
-  * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
762
-  * It's ready to be inserted into an "echo" line in one of the templates.
763
-  * NOTE: expects a trailing "." on the namespace.
764
-  * @access private
765
-  */
759
+   * Generates a reference to the given variable inside the given (possibly nested)
760
+   * block namespace. This is a string of the form:
761
+   * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
762
+   * It's ready to be inserted into an "echo" line in one of the templates.
763
+   * NOTE: expects a trailing "." on the namespace.
764
+   * @access private
765
+   */
766 766
   function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
767 767
   {
768 768
     // Strip the trailing period.
@@ -780,14 +780,14 @@  discard block
 block discarded – undo
780 780
   }
781 781
 
782 782
   /**
783
-  * Generates a reference to the array of data values for the given
784
-  * (possibly nested) block namespace. This is a string of the form:
785
-  * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
786
-  *
787
-  * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
788
-  * NOTE: does not expect a trailing "." on the blockname.
789
-  * @access private
790
-  */
783
+   * Generates a reference to the array of data values for the given
784
+   * (possibly nested) block namespace. This is a string of the form:
785
+   * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
786
+   *
787
+   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
788
+   * NOTE: does not expect a trailing "." on the blockname.
789
+   * @access private
790
+   */
791 791
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
792 792
   {
793 793
     // Get an array of the blocks involved.
@@ -823,9 +823,9 @@  discard block
 block discarded – undo
823 823
   }
824 824
 
825 825
   /**
826
-  * Write compiled file to cache directory
827
-  * @access private
828
-  */
826
+   * Write compiled file to cache directory
827
+   * @access private
828
+   */
829 829
   function compile_write($handle, $data)
830 830
   {
831 831
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 
849 849
   // Gorlum's minifier BOF
850 850
   /**
851
-  * Minifies template w/i PHP code by removing extra spaces
852
-  */
851
+   * Minifies template w/i PHP code by removing extra spaces
852
+   */
853 853
   private function minify($html)
854 854
   {
855 855
     if(!classSupernova::$config->tpl_minifier)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
140 140
     $include_blocks = $matches[1];
141
-    if($include_blocks)
141
+    if ($include_blocks)
142 142
     {
143
-      foreach($include_blocks as &$included_file)
143
+      foreach ($include_blocks as &$included_file)
144 144
       {
145 145
         $included_file .= '.tpl.html';
146 146
       }
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 
447 447
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
448 448
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
449
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
450
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
449
+    $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];';
450
+    $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];';
451 451
 
452 452
     return $tag_template_php;
453 453
   }
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
         break;
552 552
 
553 553
         case 'is':
554
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
554
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
555 555
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
556 556
 
557
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
557
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
558 558
 
559 559
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
560 560
 
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
     }
815 815
     else if ($include_last_iterator)
816 816
     {
817
-      return '$_'. $blocks[$blockcount] . '_val';
817
+      return '$_' . $blocks[$blockcount] . '_val';
818 818
     }
819 819
     else
820 820
     {
821
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
821
+      return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']';
822 822
     }
823 823
   }
824 824
 
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
     if ($fp = @fopen($filename, 'wb'))
836 836
     {
837 837
       @flock($fp, LOCK_EX);
838
-      @fwrite ($fp, $data);
838
+      @fwrite($fp, $data);
839 839
       @flock($fp, LOCK_UN);
840 840
       @fclose($fp);
841 841
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
   */
853 853
   private function minify($html)
854 854
   {
855
-    if(!classSupernova::$config->tpl_minifier)
855
+    if (!classSupernova::$config->tpl_minifier)
856 856
     {
857 857
       return $html;
858 858
     }
@@ -862,14 +862,14 @@  discard block
 block discarded – undo
862 862
     $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html);
863 863
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
864 864
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
865
-    if(!empty($pre[0]))
865
+    if (!empty($pre[0]))
866 866
     {
867
-      foreach($pre[0] as $tag)
867
+      foreach ($pre[0] as $tag)
868 868
       {
869 869
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
870 870
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
871 871
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
872
-        $html = preg_replace('/#pre#/', $tag, $html,1);
872
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
873 873
       }
874 874
     }
875 875
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -68 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
 *
36 36
 * @package phpBB3
37 37
 */
38
-class template_compile
39
-{
38
+class template_compile {
40 39
   var $template;
41 40
 
42 41
   // Various storage arrays
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
   /**
47 46
   * constuctor
48 47
   */
49
-  public function template_compile(&$template)
50
-  {
48
+  public function template_compile(&$template) {
51 49
     $this->template = &$template;
52 50
   }
53 51
 
@@ -55,8 +53,7 @@  discard block
 block discarded – undo
55 53
   * Load template source from file
56 54
   * @access private
57 55
   */
58
-  public function _tpl_load_file($handle, $store_in_db = false)
59
-  {
56
+  public function _tpl_load_file($handle, $store_in_db = false) {
60 57
     // Try and open template for read
61 58
     if (!file_exists($this->template->files[$handle]))
62 59
     {
@@ -64,8 +61,7 @@  discard block
 block discarded – undo
64 61
       {
65 62
         return;
66 63
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
67
-      }
68
-      else
64
+      } else
69 65
       {
70 66
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
71 67
       }
@@ -101,8 +97,7 @@  discard block
 block discarded – undo
101 97
   * the ones that exist in zend_language_scanner.l
102 98
   * @access private
103 99
   */
104
-  public function remove_php_tags(&$code)
105
-  {
100
+  public function remove_php_tags(&$code) {
106 101
     // This matches the information gathered from the internal PHP lexer
107 102
     $match = array(
108 103
       '#<([\?%])=?.*?\1>#s',
@@ -117,8 +112,7 @@  discard block
 block discarded – undo
117 112
   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
118 113
   * @access private
119 114
   */
120
-  public function compile($code, $no_echo = false, $echo_var = '')
121
-  {
115
+  public function compile($code, $no_echo = false, $echo_var = '') {
122 116
     if ($echo_var)
123 117
     {
124 118
       global $$echo_var;
@@ -221,15 +215,13 @@  discard block
 block discarded – undo
221 215
               $var = substr($temp, 2, -1);
222 216
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
223 217
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
224
-            }
225
-            else
218
+            } else
226 219
             {
227 220
               $var = substr($temp, 1, -1);
228 221
               //$file = $this->template->_rootref[$var];
229 222
               $temp = "\$this->_rootref['$var']";
230 223
             }
231
-          }
232
-          else
224
+          } else
233 225
           {
234 226
             $file = $temp;
235 227
           }
@@ -288,8 +280,7 @@  discard block
 block discarded – undo
288 280
   * Compile variables
289 281
   * @access private
290 282
   */
291
-  public function compile_var_tags(&$text_blocks)
292
-  {
283
+  public function compile_var_tags(&$text_blocks) {
293 284
     // change template varrefs into PHP varrefs
294 285
     $varrefs = array();
295 286
 
@@ -350,8 +341,7 @@  discard block
 block discarded – undo
350 341
   * Compile blocks
351 342
   * @access private
352 343
   */
353
-  public function compile_tag_block($tag_args)
354
-  {
344
+  public function compile_tag_block($tag_args) {
355 345
     $no_nesting = false;
356 346
 
357 347
     // Is the designer wanting to call another loop in a loop?
@@ -374,8 +364,7 @@  discard block
 block discarded – undo
374 364
       if ($match[2] < 0)
375 365
       {
376 366
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
377
-      }
378
-      else
367
+      } else
379 368
       {
380 369
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
381 370
       }
@@ -383,17 +372,14 @@  discard block
 block discarded – undo
383 372
       if (strlen($match[3]) < 1 || $match[3] == -1)
384 373
       {
385 374
         $loop_end = '$_' . $tag_args . '_count';
386
-      }
387
-      else if ($match[3] >= 0)
375
+      } else if ($match[3] >= 0)
388 376
       {
389 377
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
390
-      }
391
-      else //if ($match[3] < -1)
378
+      } else //if ($match[3] < -1)
392 379
       {
393 380
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
394 381
       }
395
-    }
396
-    else
382
+    } else
397 383
     {
398 384
       $loop_start = 0;
399 385
       $loop_end = '$_' . $tag_args . '_count';
@@ -406,8 +392,7 @@  discard block
 block discarded – undo
406 392
     {
407 393
       // We need to implode $no_nesting times from the end...
408 394
       $block = array_slice($this->block_names, -$no_nesting);
409
-    }
410
-    else
395
+    } else
411 396
     {
412 397
       $block = $this->block_names;
413 398
     }
@@ -417,8 +402,7 @@  discard block
 block discarded – undo
417 402
       // Block is not nested.
418 403
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
419 404
       $varref = "\$this->_tpldata['$tag_args']";
420
-    }
421
-    else
405
+    } else
422 406
     {
423 407
       // This block is nested.
424 408
       // Generate a namespace string for this block.
@@ -457,8 +441,7 @@  discard block
 block discarded – undo
457 441
   * some adaptions for our block level methods
458 442
   * @access private
459 443
   */
460
-  public function compile_tag_if($tag_args, $elseif)
461
-  {
444
+  public function compile_tag_if($tag_args, $elseif) {
462 445
     // Tokenize args for 'if' tag.
463 446
     preg_match_all('/(?:
464 447
       "[^"\\\\]*(?:\\\\.[^"\\\\]*)*"         |
@@ -566,8 +549,7 @@  discard block
 block discarded – undo
566 549
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
567 550
           {
568 551
             $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] . '\']');
569
-          }
570
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
552
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
571 553
           {
572 554
             // Allow checking if loops are set with .loopname
573 555
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -583,8 +565,7 @@  discard block
 block discarded – undo
583 565
 
584 566
               // Add the block reference for the last child.
585 567
               $varref .= "['" . $block . "']";
586
-            }
587
-            else
568
+            } else
588 569
             {
589 570
               $varref = '$this->_tpldata';
590 571
 
@@ -592,8 +573,7 @@  discard block
 block discarded – undo
592 573
               $varref .= "['" . $blocks[0] . "']";
593 574
             }
594 575
             $token = "sizeof($varref)";
595
-          }
596
-          else if (!empty($token))
576
+          } else if (!empty($token))
597 577
           {
598 578
             $token = '(' . $token . ')';
599 579
           }
@@ -614,8 +594,7 @@  discard block
 block discarded – undo
614 594
   * Compile DEFINE tags
615 595
   * @access private
616 596
   */
617
-  public function compile_tag_define($tag_args, $op)
618
-  {
597
+  public function compile_tag_define($tag_args, $op) {
619 598
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
620 599
 
621 600
     if (empty($match[2]) || (!isset($match[4]) && $op))
@@ -638,8 +617,7 @@  discard block
 block discarded – undo
638 617
 
639 618
       // Now replace the php code
640 619
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
641
-    }
642
-    else
620
+    } else
643 621
     {
644 622
       preg_match('#true|false|\.#i', $match[4], $type);
645 623
 
@@ -667,8 +645,7 @@  discard block
 block discarded – undo
667 645
   * Compile INCLUDE tag
668 646
   * @access private
669 647
   */
670
-  public function compile_tag_include($tag_args)
671
-  {
648
+  public function compile_tag_include($tag_args) {
672 649
     // Process dynamic includes
673 650
     if ($tag_args[0] == '$')
674 651
     {
@@ -682,8 +659,7 @@  discard block
 block discarded – undo
682 659
   * Compile INCLUDE_PHP tag
683 660
   * @access private
684 661
   */
685
-  public function compile_tag_include_php($tag_args)
686
-  {
662
+  public function compile_tag_include_php($tag_args) {
687 663
     return "\$this->_php_include('$tag_args');";
688 664
   }
689 665
 
@@ -692,8 +668,7 @@  discard block
 block discarded – undo
692 668
   * This is from Smarty
693 669
   * @access private
694 670
   */
695
-  public function _parse_is_expr($is_arg, $tokens)
696
-  {
671
+  public function _parse_is_expr($is_arg, $tokens) {
697 672
     $expr_end = 0;
698 673
     $negate_expr = false;
699 674
 
@@ -701,8 +676,7 @@  discard block
 block discarded – undo
701 676
     {
702 677
       $negate_expr = true;
703 678
       $expr_type = array_shift($tokens);
704
-    }
705
-    else
679
+    } else
706 680
     {
707 681
       $expr_type = $first_token;
708 682
     }
@@ -716,8 +690,7 @@  discard block
 block discarded – undo
716 690
           $expr_end++;
717 691
           $expr_arg = $tokens[$expr_end++];
718 692
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
719
-        }
720
-        else
693
+        } else
721 694
         {
722 695
           $expr = "!($is_arg & 1)";
723 696
         }
@@ -729,8 +702,7 @@  discard block
 block discarded – undo
729 702
           $expr_end++;
730 703
           $expr_arg = $tokens[$expr_end++];
731 704
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
732
-        }
733
-        else
705
+        } else
734 706
         {
735 707
           $expr = "($is_arg & 1)";
736 708
         }
@@ -764,8 +736,7 @@  discard block
 block discarded – undo
764 736
   * NOTE: expects a trailing "." on the namespace.
765 737
   * @access private
766 738
   */
767
-  public function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
768
-  {
739
+  public function generate_block_varref($namespace, $varname, $echo = true, $defop = false) {
769 740
     // Strip the trailing period.
770 741
     $namespace = substr($namespace, 0, -1);
771 742
 
@@ -789,8 +760,7 @@  discard block
 block discarded – undo
789 760
   * NOTE: does not expect a trailing "." on the blockname.
790 761
   * @access private
791 762
   */
792
-  public function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
793
-  {
763
+  public function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) {
794 764
     // Get an array of the blocks involved.
795 765
     $blocks = explode('.', $blockname);
796 766
     $blockcount = sizeof($blocks) - 1;
@@ -812,12 +782,10 @@  discard block
 block discarded – undo
812 782
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
813 783
       }
814 784
       return $varref;
815
-    }
816
-    else if ($include_last_iterator)
785
+    } else if ($include_last_iterator)
817 786
     {
818 787
       return '$_'. $blocks[$blockcount] . '_val';
819
-    }
820
-    else
788
+    } else
821 789
     {
822 790
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
823 791
     }
@@ -827,8 +795,7 @@  discard block
 block discarded – undo
827 795
   * Write compiled file to cache directory
828 796
   * @access private
829 797
   */
830
-  public function compile_write($handle, $data)
831
-  {
798
+  public function compile_write($handle, $data) {
832 799
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
833 800
 
834 801
     $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
@@ -851,8 +818,7 @@  discard block
 block discarded – undo
851 818
   /**
852 819
   * Minifies template w/i PHP code by removing extra spaces
853 820
   */
854
-  private function minify($html)
855
-  {
821
+  private function minify($html) {
856 822
     if(!classSupernova::$config->tpl_minifier)
857 823
     {
858 824
       return $html;
Please login to merge, or discard this patch.