Completed
Push — trunk ( 0e7a2e...6a6c5e )
by SuperNova.WS
07:28
created
classes/template.php 1 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();
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
   }
80 80
 
81 81
   /**
82
-  * Set template location
83
-  * @access public
84
-  */
82
+   * Set template location
83
+   * @access public
84
+   */
85 85
   function set_template()
86 86
   {
87 87
     global $user;
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
   }
121 121
 
122 122
   /**
123
-  * Set custom template location (able to use directory outside of phpBB)
124
-  * @access public
125
-  */
123
+   * Set custom template location (able to use directory outside of phpBB)
124
+   * @access public
125
+   */
126 126
   function set_custom_template($template_path, $template_name, $fallback_template_path = false)
127 127
   {
128 128
     global $user;
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
   }
162 162
 
163 163
   /**
164
-  * Sets the template filenames for handles. $filename_array
165
-  * should be a hash of handle => filename pairs.
166
-  * @access public
167
-  */
164
+   * Sets the template filenames for handles. $filename_array
165
+   * should be a hash of handle => filename pairs.
166
+   * @access public
167
+   */
168 168
   function set_filenames($filename_array)
169 169
   {
170 170
     if (!is_array($filename_array))
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
   }
192 192
 
193 193
   /**
194
-  * Destroy template data set
195
-  * @access public
196
-  */
194
+   * Destroy template data set
195
+   * @access public
196
+   */
197 197
   function destroy()
198 198
   {
199 199
     $this->_tpldata = array('.' => array(0 => array()));
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
   }
202 202
 
203 203
   /**
204
-  * Reset/empty complete block
205
-  * @access public
206
-  */
204
+   * Reset/empty complete block
205
+   * @access public
206
+   */
207 207
   function destroy_block_vars($blockname)
208 208
   {
209 209
     if (strpos($blockname, '.') !== false)
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
   }
232 232
 
233 233
   /**
234
-  * Display handle
235
-  * @access public
236
-  */
234
+   * Display handle
235
+   * @access public
236
+   */
237 237
   function display($handle, $include_once = true)
238 238
   {
239 239
     if (defined('IN_ERROR_HANDLER'))
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
   }
259 259
 
260 260
   /**
261
-  * Display the handle and assign the output to a template variable or return the compiled result.
262
-  * @access public
263
-  */
261
+   * Display the handle and assign the output to a template variable or return the compiled result.
262
+   * @access public
263
+   */
264 264
   function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
265 265
   {
266 266
     ob_start();
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
   }
279 279
 
280 280
   /**
281
-  * Load a compiled template if possible, if not, recompile it
282
-  * @access private
283
-  */
281
+   * Load a compiled template if possible, if not, recompile it
282
+   * @access private
283
+   */
284 284
   function _tpl_load(&$handle)
285 285
   {
286 286
     global $user, $config;
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
   }
459 459
 
460 460
   /**
461
-  * Assign key variable pairs from an array
462
-  * @access public
463
-  */
461
+   * Assign key variable pairs from an array
462
+   * @access public
463
+   */
464 464
   function assign_vars($vararray)
465 465
   {
466 466
     foreach ($vararray as $key => $val)
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
   }
473 473
 
474 474
   /**
475
-  * Assign a single variable to a single key
476
-  * @access public
477
-  */
475
+   * Assign a single variable to a single key
476
+   * @access public
477
+   */
478 478
   function assign_var($varname, $varval)
479 479
   {
480 480
     $this->_rootref[$varname] = $varval;
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
   }
484 484
 
485 485
   /**
486
-  * Assign key variable pairs from an array to a specified block
487
-  * @access public
488
-  */
486
+   * Assign key variable pairs from an array to a specified block
487
+   * @access public
488
+   */
489 489
   function assign_block_vars($blockname, $vararray)
490 490
   {
491 491
     if (strpos($blockname, '.') !== false)
@@ -550,33 +550,33 @@  discard block
 block discarded – undo
550 550
   }
551 551
 
552 552
   /**
553
-  * Change already assigned key variable pair (one-dimensional - single loop entry)
554
-  *
555
-  * An example of how to use this function:
556
-  * {@example alter_block_array.php}
557
-  *
558
-  * @param  string  $blockname  the blockname, for example 'loop'
559
-  * @param  array $vararray the var array to insert/add or merge
560
-  * @param  mixed $key    Key to search for
561
-  *
562
-  * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
563
-  *
564
-  * int: Position [the position to change or insert at directly given]
565
-  *
566
-  * If key is false the position is set to 0
567
-  * If key is true the position is set to the last entry
568
-  *
569
-  * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
570
-  *
571
-  * If insert, the vararray is inserted at the given position (position counting from zero).
572
-  * 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).
573
-  *
574
-  * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
575
-  * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
576
-  *
577
-  * @return bool false on error, true on success
578
-  * @access public
579
-  */
553
+   * Change already assigned key variable pair (one-dimensional - single loop entry)
554
+   *
555
+   * An example of how to use this function:
556
+   * {@example alter_block_array.php}
557
+   *
558
+   * @param  string  $blockname  the blockname, for example 'loop'
559
+   * @param  array $vararray the var array to insert/add or merge
560
+   * @param  mixed $key    Key to search for
561
+   *
562
+   * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
563
+   *
564
+   * int: Position [the position to change or insert at directly given]
565
+   *
566
+   * If key is false the position is set to 0
567
+   * If key is true the position is set to the last entry
568
+   *
569
+   * @param  string  $mode   Mode to execute (valid modes are 'insert' and 'change')
570
+   *
571
+   * If insert, the vararray is inserted at the given position (position counting from zero).
572
+   * 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).
573
+   *
574
+   * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
575
+   * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
576
+   *
577
+   * @return bool false on error, true on success
578
+   * @access public
579
+   */
580 580
   function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
581 581
   {
582 582
     if (strpos($blockname, '.') !== false)
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
   }
661 661
 
662 662
   /**
663
-  * Include a separate template
664
-  * @access private
665
-  */
663
+   * Include a separate template
664
+   * @access private
665
+   */
666 666
   function _tpl_include($filename, $include = true)
667 667
   {
668 668
     // This is used to access global vars
@@ -691,9 +691,9 @@  discard block
 block discarded – undo
691 691
   }
692 692
 
693 693
   /**
694
-  * Include a php-file
695
-  * @access private
696
-  */
694
+   * Include a php-file
695
+   * @access private
696
+   */
697 697
   function _php_include($filename)
698 698
   {
699 699
     $file = $this->rootPhysical . $filename;
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
   }
709 709
 
710 710
   /**
711
-  * Assign key variable pairs from an array with block support
712
-  * @access public
713
-  */
711
+   * Assign key variable pairs from an array with block support
712
+   * @access public
713
+   */
714 714
   function assign_recursive($values, $name = '')
715 715
   {
716 716
     if(isset($values['.']))
Please login to merge, or discard this patch.
fleet.php 1 patch
Switch Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -77,121 +77,121 @@  discard block
 block discarded – undo
77 77
 }
78 78
 
79 79
 switch ($fleet_page) {
80
-  case 3:
80
+    case 3:
81 81
 
82
-  case 2:
83
-    $fleet_group_mr = sys_get_param_id('fleet_group');
84
-    $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
85
-    $fleetarray = is_array($fleetarray) ? $fleetarray : array();
82
+    case 2:
83
+      $fleet_group_mr = sys_get_param_id('fleet_group');
84
+      $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
85
+      $fleetarray = is_array($fleetarray) ? $fleetarray : array();
86 86
 
87
-    foreach($fleetarray as $ship_id => &$ship_amount) {
88
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
89
-        $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
90
-        die();
91
-      }
92
-      $ship_amount = floatval($ship_amount);
93
-    }
94
-
95
-    $UsedPlanet = false;
96
-    $YourPlanet = false;
97
-    $missiontype = array();
98
-    if ($planet > SN::$config->game_maxPlanet) {
99
-      $target_mission = MT_EXPLORE;
100
-      $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
101
-    } elseif ($galaxy && $system && $planet) {
102
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
103
-
104
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
105
-
106
-      if ($TargetPlanet['id_owner']) {
107
-        $UsedPlanet = true;
108
-        if ($TargetPlanet['id_owner'] == $user['id']) {
109
-          $YourPlanet = true;
87
+      foreach($fleetarray as $ship_id => &$ship_amount) {
88
+        if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
89
+          $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
90
+          die();
110 91
         }
92
+        $ship_amount = floatval($ship_amount);
111 93
       }
112 94
 
113
-      if (!$UsedPlanet) {
114
-        if ($fleetarray[SHIP_COLONIZER]) {
115
-          $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
116
-          $target_mission = MT_COLONIZE;
117
-          $planet_type = PT_PLANET;
118
-        } else {
119
-          messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
120
-        }
121
-      } else {
122
-        $recyclers = 0;
123
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
124
-          $recyclers += $fleetarray[$recycler_id];
95
+      $UsedPlanet = false;
96
+      $YourPlanet = false;
97
+      $missiontype = array();
98
+      if ($planet > SN::$config->game_maxPlanet) {
99
+        $target_mission = MT_EXPLORE;
100
+        $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
101
+      } elseif ($galaxy && $system && $planet) {
102
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
103
+
104
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
105
+
106
+        if ($TargetPlanet['id_owner']) {
107
+          $UsedPlanet = true;
108
+          if ($TargetPlanet['id_owner'] == $user['id']) {
109
+            $YourPlanet = true;
110
+          }
125 111
         }
126
-        if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
127
-          $target_mission = MT_RECYCLE;
128
-          $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
129
-        } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
130
-          if ($YourPlanet) {
131
-            $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
132
-            $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
112
+
113
+        if (!$UsedPlanet) {
114
+          if ($fleetarray[SHIP_COLONIZER]) {
115
+            $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
116
+            $target_mission = MT_COLONIZE;
117
+            $planet_type = PT_PLANET;
133 118
           } else {
134
-            // Not Your Planet
135
-            if ($fleetarray[SHIP_SPY]) {
136
-              // Only spy missions if any spy
137
-              $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
119
+            messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
120
+          }
121
+        } else {
122
+          $recyclers = 0;
123
+          foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
124
+            $recyclers += $fleetarray[$recycler_id];
125
+          }
126
+          if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
127
+            $target_mission = MT_RECYCLE;
128
+            $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
129
+          } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
130
+            if ($YourPlanet) {
131
+              $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
132
+              $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
138 133
             } else {
139
-              // If no spies...
140
-              if ($fleet_group_mr) {
141
-                $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
134
+              // Not Your Planet
135
+              if ($fleetarray[SHIP_SPY]) {
136
+                // Only spy missions if any spy
137
+                $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
142 138
               } else {
143
-                $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
144
-                $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
145
-
146
-                $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
147
-
148
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
149
-                  $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
139
+                // If no spies...
140
+                if ($fleet_group_mr) {
141
+                  $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
142
+                } else {
143
+                  $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
144
+                  $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
145
+
146
+                  $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
147
+
148
+                  if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
149
+                    $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
150
+                  }
150 151
                 }
151 152
               }
152 153
             }
153 154
           }
154 155
         }
155 156
       }
156
-    }
157
-
158
-    if (!$target_mission && is_array($missiontype)) {
159
-      $target_mission = MT_ATTACK;
160
-    }
161
-
162
-//    $sn_group_missions = sn_get_groups('missions');
163
-//    foreach($sn_group_missions as $mission_id => $cork) {
164
-//      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
165
-//    }
166
-//
167
-//
168
-    ksort($missiontype);
169
-
170
-    $speed_percent = sys_get_param_int('speed', 10);
171
-    $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
172
-
173
-//    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
174
-    $fleet_speed   = $travel_data['fleet_speed'];
175
-    $distance      = $travel_data['distance'];
176
-    $duration      = $travel_data['duration'];
177
-    $consumption   = $travel_data['consumption'];
178
-  // No Break
179
-
180
-  case 1:
181
-    if ($galaxy && $system && $planet) {
182
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
183
-
184
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
185
-    }
186
-
187
-  case 0:
188
-    $template_result += array(
189
-      'thisgalaxy'      => $planetrow['galaxy'],
190
-      'thissystem'      => $planetrow['system'],
191
-      'thisplanet'      => $planetrow['planet'],
192
-      'thisplanet_type' => $planetrow['planet_type'],
193
-    );
194
-  // no break
157
+
158
+      if (!$target_mission && is_array($missiontype)) {
159
+        $target_mission = MT_ATTACK;
160
+      }
161
+
162
+  //    $sn_group_missions = sn_get_groups('missions');
163
+  //    foreach($sn_group_missions as $mission_id => $cork) {
164
+  //      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
165
+  //    }
166
+  //
167
+  //
168
+      ksort($missiontype);
169
+
170
+      $speed_percent = sys_get_param_int('speed', 10);
171
+      $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
172
+
173
+  //    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
174
+      $fleet_speed   = $travel_data['fleet_speed'];
175
+      $distance      = $travel_data['distance'];
176
+      $duration      = $travel_data['duration'];
177
+      $consumption   = $travel_data['consumption'];
178
+    // No Break
179
+
180
+    case 1:
181
+      if ($galaxy && $system && $planet) {
182
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
183
+
184
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
185
+      }
186
+
187
+    case 0:
188
+      $template_result += array(
189
+        'thisgalaxy'      => $planetrow['galaxy'],
190
+        'thissystem'      => $planetrow['system'],
191
+        'thisplanet'      => $planetrow['planet'],
192
+        'thisplanet_type' => $planetrow['planet_type'],
193
+      );
194
+    // no break
195 195
 
196 196
 }
197 197
 
@@ -213,35 +213,35 @@  discard block
 block discarded – undo
213 213
 }
214 214
 
215 215
 switch($fleet_page) {
216
-  case 1:
217
-    require('includes/includes/flt_page1.inc');
218
-  break;
219
-
220
-  case 2:
221
-    require_once('includes/includes/flt_page2.inc');
222
-    sn_fleet_page2();
223
-  break;
224
-
225
-  case 3:
226
-    require_once('includes/includes/flt_page3.inc');
227
-    sn_fleet_page3();
228
-  break;
229
-
230
-  case 4:
231
-    require('includes/includes/flt_page4.inc');
232
-  break;
233
-
234
-  case 5:
235
-    $template = gettemplate('fleet5', true);
236
-    $pageFleet5Gathering = new \Pages\Deprecated\PageFleet5Gathering();
237
-    $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
238
-    // Building list of own planets & moons
239
-    $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
240
-  break;
241
-
242
-  default:
243
-    define('SN_RENDER_NAVBAR_PLANET', true);
244
-
245
-    require('includes/includes/flt_page0.inc');
246
-  break;
216
+    case 1:
217
+      require('includes/includes/flt_page1.inc');
218
+    break;
219
+
220
+    case 2:
221
+      require_once('includes/includes/flt_page2.inc');
222
+      sn_fleet_page2();
223
+    break;
224
+
225
+    case 3:
226
+      require_once('includes/includes/flt_page3.inc');
227
+      sn_fleet_page3();
228
+    break;
229
+
230
+    case 4:
231
+      require('includes/includes/flt_page4.inc');
232
+    break;
233
+
234
+    case 5:
235
+      $template = gettemplate('fleet5', true);
236
+      $pageFleet5Gathering = new \Pages\Deprecated\PageFleet5Gathering();
237
+      $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
238
+      // Building list of own planets & moons
239
+      $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
240
+    break;
241
+
242
+    default:
243
+      define('SN_RENDER_NAVBAR_PLANET', true);
244
+
245
+      require('includes/includes/flt_page0.inc');
246
+    break;
247 247
 }
Please login to merge, or discard this patch.