Completed
Pull Request — develop (#689)
by Alexander
05:50
created
manager/includes/charsets.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -65,26 +65,26 @@
 block discarded – undo
65 65
 $_['macintosh']         = 'Western European (Mac) - macintosh';
66 66
 $_['Windows-1252']      = 'Western European (Windows) - Windows-1252';
67 67
 
68
-if($modx_charset     == 'euc-jp')      $_['euc-jp']      = 'Japanese (EUC) - euc-jp';
69
-elseif($modx_charset == 'shift_jis')   $_['shift_jis']   = 'Japanese (Shift-JIS) - shift_jis';
70
-elseif($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp';
71
-elseif($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP';
72
-elseif($modx_charset == 'EUC-CN')            $_['EUC-CN']            = 'Chinese Simplified (EUC) - EUC-CN';
73
-elseif($modx_charset == 'hz-gb-2312')        $_['hz-gb-2312']        = 'Chinese Simplified (HZ) - hz-gb-2312';
74
-elseif($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp';
75
-elseif($modx_charset == 'x-Chinese-CNS')     $_['x-Chinese-CNS']     = 'Chinese Traditional (CNS) - x-Chinese-CNS';
76
-elseif($modx_charset == 'x-Chinese-Eten')    $_['x-Chinese-Eten']    = 'Chinese Traditional (Eten) - x-Chinese-Eten';
77
-elseif($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad';
78
-elseif($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987';
79
-elseif($modx_charset == 'euc-kr')         $_['euc-kr']         = 'Korean (EUC) - euc-kr';
80
-elseif($modx_charset == 'iso-2022-kr')    $_['iso-2022-kr']    = 'Korean (ISO) - iso-2022-kr';
81
-elseif($modx_charset == 'Johab')          $_['Johab']          = 'Korean (Johab) - Johab';
82
-elseif($modx_charset == 'x-mac-korean')   $_['x-mac-korean']   = 'Korean (Mac) - x-mac-korean';
68
+if ($modx_charset == 'euc-jp')      $_['euc-jp']      = 'Japanese (EUC) - euc-jp';
69
+elseif ($modx_charset == 'shift_jis')   $_['shift_jis']   = 'Japanese (Shift-JIS) - shift_jis';
70
+elseif ($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp';
71
+elseif ($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP';
72
+elseif ($modx_charset == 'EUC-CN')            $_['EUC-CN']            = 'Chinese Simplified (EUC) - EUC-CN';
73
+elseif ($modx_charset == 'hz-gb-2312')        $_['hz-gb-2312']        = 'Chinese Simplified (HZ) - hz-gb-2312';
74
+elseif ($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp';
75
+elseif ($modx_charset == 'x-Chinese-CNS')     $_['x-Chinese-CNS']     = 'Chinese Traditional (CNS) - x-Chinese-CNS';
76
+elseif ($modx_charset == 'x-Chinese-Eten')    $_['x-Chinese-Eten']    = 'Chinese Traditional (Eten) - x-Chinese-Eten';
77
+elseif ($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad';
78
+elseif ($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987';
79
+elseif ($modx_charset == 'euc-kr')         $_['euc-kr']         = 'Korean (EUC) - euc-kr';
80
+elseif ($modx_charset == 'iso-2022-kr')    $_['iso-2022-kr']    = 'Korean (ISO) - iso-2022-kr';
81
+elseif ($modx_charset == 'Johab')          $_['Johab']          = 'Korean (Johab) - Johab';
82
+elseif ($modx_charset == 'x-mac-korean')   $_['x-mac-korean']   = 'Korean (Mac) - x-mac-korean';
83 83
 
84 84
 $tpl = '<option value="%s" %s>%s</option>';
85 85
 $options = array();
86
-foreach($_ as $value=>$label) {
87
-    $selected = $value===$modx_charset ? 'selected' : '';
86
+foreach ($_ as $value=>$label) {
87
+    $selected = $value === $modx_charset ? 'selected' : '';
88 88
     $options[] = sprintf($tpl, $value, $selected, $label);
89 89
 }
90 90
 echo implode("\n", $options);
Please login to merge, or discard this patch.
manager/media/rss/rss_parse.inc 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 define('RSS', 'RSS');
24 24
 define('ATOM', 'Atom');
25 25
 
26
-require_once (MAGPIE_DIR . 'rss_utils.inc');
26
+require_once (MAGPIE_DIR.'rss_utils.inc');
27 27
 
28 28
 /**
29 29
 * Hybrid parser, and object, takes RSS as a string and returns a simple object.
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
 * see: rss_fetch.inc for a simpler interface with integrated caching support
32 32
 *
33 33
 */
34
-class MagpieRSS {
34
+class MagpieRSS{
35 35
     var $parser;
36 36
 
37
-    var $current_item   = array();  // item currently being parsed
38
-    var $items          = array();  // collection of parsed items
39
-    var $channel        = array();  // hash of channel fields
37
+    var $current_item   = array(); // item currently being parsed
38
+    var $items          = array(); // collection of parsed items
39
+    var $channel        = array(); // hash of channel fields
40 40
     var $textinput      = array();
41 41
     var $image          = array();
42 42
     var $feed_type;
43 43
     var $feed_version;
44
-    var $encoding       = '';       // output encoding of parsed rss
44
+    var $encoding       = ''; // output encoding of parsed rss
45 45
 
46
-    var $_source_encoding = '';     // only set if we have to parse xml prolog
46
+    var $_source_encoding = ''; // only set if we have to parse xml prolog
47 47
 
48 48
     var $ERROR = "";
49 49
     var $WARNING = "";
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      *                                  source encoding. (caveat emptor)
92 92
      *
93 93
      */
94
-    function __construct($source, $output_encoding='ISO-8859-1',
95
-                        $input_encoding=null, $detect_encoding=true)
94
+    function __construct($source, $output_encoding = 'ISO-8859-1',
95
+                        $input_encoding = null, $detect_encoding = true)
96 96
     {
97 97
         # if PHP xml isn't compiled in, die
98 98
         #
99 99
         if (!function_exists('xml_parser_create')) {
100
-            $this->error( "Failed to load PHP's XML Extension. " .
100
+            $this->error("Failed to load PHP's XML Extension. ".
101 101
                           "http://www.php.net/manual/en/ref.xml.php",
102
-                           E_USER_ERROR );
102
+                           E_USER_ERROR);
103 103
         }
104 104
 
105 105
         list($parser, $source) = $this->create_parser($source,
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 
108 108
 
109 109
         if (!is_resource($parser)) {
110
-            $this->error( "Failed to create an instance of PHP's XML parser. " .
110
+            $this->error("Failed to create an instance of PHP's XML parser. ".
111 111
                           "http://www.php.net/manual/en/ref.xml.php",
112
-                          E_USER_ERROR );
112
+                          E_USER_ERROR);
113 113
         }
114 114
 
115 115
 
@@ -118,57 +118,57 @@  discard block
 block discarded – undo
118 118
         # pass in parser, and a reference to this object
119 119
         # setup handlers
120 120
         #
121
-        xml_set_object( $this->parser, $this );
121
+        xml_set_object($this->parser, $this);
122 122
         xml_set_element_handler($this->parser,
123
-                'feed_start_element', 'feed_end_element' );
123
+                'feed_start_element', 'feed_end_element');
124 124
 
125
-        xml_set_character_data_handler( $this->parser, 'feed_cdata' );
125
+        xml_set_character_data_handler($this->parser, 'feed_cdata');
126 126
 
127
-        $status = xml_parse( $this->parser, $source );
127
+        $status = xml_parse($this->parser, $source);
128 128
 
129
-        if (! $status ) {
130
-            $errorcode = xml_get_error_code( $this->parser );
131
-            if ( $errorcode != XML_ERROR_NONE ) {
132
-                $xml_error = xml_error_string( $errorcode );
129
+        if (!$status) {
130
+            $errorcode = xml_get_error_code($this->parser);
131
+            if ($errorcode != XML_ERROR_NONE) {
132
+                $xml_error = xml_error_string($errorcode);
133 133
                 $error_line = xml_get_current_line_number($this->parser);
134 134
                 $error_col = xml_get_current_column_number($this->parser);
135 135
                 $errormsg = "$xml_error at line $error_line, column $error_col";
136 136
 
137
-                $this->error( $errormsg );
137
+                $this->error($errormsg);
138 138
             }
139 139
         }
140 140
 
141
-        xml_parser_free( $this->parser );
141
+        xml_parser_free($this->parser);
142 142
 
143 143
         $this->normalize();
144 144
     }
145 145
 
146
-    function feed_start_element($p, $element, &$attrs) {
146
+    function feed_start_element($p, $element, &$attrs){
147 147
         $el = $element = strtolower($element);
148 148
         $attrs = array_change_key_case($attrs, CASE_LOWER);
149 149
 
150 150
         // check for a namespace, and split if found
151 151
         $ns = false;
152
-        if ( strpos( $element, ':' ) ) {
153
-            list($ns, $el) = explode( ':', $element, 2);
152
+        if (strpos($element, ':')) {
153
+            list($ns, $el) = explode(':', $element, 2);
154 154
         }
155
-        if ( $ns and $ns != 'rdf' ) {
155
+        if ($ns and $ns != 'rdf') {
156 156
             $this->current_namespace = $ns;
157 157
         }
158 158
 
159 159
         # if feed type isn't set, then this is first element of feed
160 160
         # identify feed from root element
161 161
         #
162
-        if (!isset($this->feed_type) ) {
163
-            if ( $el == 'rdf' ) {
162
+        if (!isset($this->feed_type)) {
163
+            if ($el == 'rdf') {
164 164
                 $this->feed_type = RSS;
165 165
                 $this->feed_version = '1.0';
166 166
             }
167
-            elseif ( $el == 'rss' ) {
167
+            elseif ($el == 'rss') {
168 168
                 $this->feed_type = RSS;
169 169
                 $this->feed_version = $attrs['version'];
170 170
             }
171
-            elseif ( $el == 'feed' ) {
171
+            elseif ($el == 'feed') {
172 172
                 $this->feed_type = ATOM;
173 173
                 $this->feed_version = $attrs['version'];
174 174
                 $this->inchannel = true;
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
             return;
177 177
         }
178 178
 
179
-        if ( $el == 'channel' )
179
+        if ($el == 'channel')
180 180
         {
181 181
             $this->inchannel = true;
182 182
         }
183
-        elseif ($el == 'item' or $el == 'entry' )
183
+        elseif ($el == 'item' or $el == 'entry')
184 184
         {
185 185
             $this->initem = true;
186
-            if ( isset($attrs['rdf:about']) ) {
186
+            if (isset($attrs['rdf:about'])) {
187 187
                 $this->current_item['about'] = $attrs['rdf:about'];
188 188
             }
189 189
         }
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
         }
208 208
 
209 209
         # handle atom content constructs
210
-        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
210
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
211 211
         {
212 212
             // avoid clashing w/ RSS mod_content
213
-            if ($el == 'content' ) {
213
+            if ($el == 'content') {
214 214
                 $el = 'atom_content';
215 215
             }
216 216
 
@@ -220,31 +220,31 @@  discard block
 block discarded – undo
220 220
         }
221 221
 
222 222
         // if inside an Atom content construct (e.g. content or summary) field treat tags as text
223
-        elseif ($this->feed_type == ATOM and $this->incontent )
223
+        elseif ($this->feed_type == ATOM and $this->incontent)
224 224
         {
225 225
             // if tags are inlined, then flatten
226 226
             $attrs_str = implode(' ',
227 227
                     array_map('map_attrs',
228 228
                     array_keys($attrs),
229
-                    array_values($attrs) ) );
229
+                    array_values($attrs)));
230 230
 
231
-            $this->append_content( "<$element $attrs_str>"  );
231
+            $this->append_content("<$element $attrs_str>");
232 232
 
233
-            array_unshift( $this->stack, $el );
233
+            array_unshift($this->stack, $el);
234 234
         }
235 235
 
236 236
         // Atom support many links per containging element.
237 237
         // Magpie treats link elements of type rel='alternate'
238 238
         // as being equivalent to RSS's simple link element.
239 239
         //
240
-        elseif ($this->feed_type == ATOM and $el == 'link' )
240
+        elseif ($this->feed_type == ATOM and $el == 'link')
241 241
         {
242
-            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
242
+            if (isset($attrs['rel']) and $attrs['rel'] == 'alternate')
243 243
             {
244 244
                 $link_el = 'link';
245 245
             }
246 246
             else {
247
-                $link_el = 'link_' . $attrs['rel'];
247
+                $link_el = 'link_'.$attrs['rel'];
248 248
             }
249 249
 
250 250
             $this->append($link_el, $attrs['href']);
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 
258 258
 
259 259
 
260
-    function feed_cdata ($p, $text) {
260
+    function feed_cdata($p, $text){
261 261
         if ($this->feed_type == ATOM and $this->incontent)
262 262
         {
263
-            $this->append_content( $text );
263
+            $this->append_content($text);
264 264
         }
265 265
         else {
266 266
             $current_el = implode('_', array_reverse($this->stack));
@@ -268,35 +268,35 @@  discard block
 block discarded – undo
268 268
         }
269 269
     }
270 270
 
271
-    function feed_end_element ($p, $el) {
271
+    function feed_end_element($p, $el){
272 272
         $el = strtolower($el);
273 273
 
274
-        if ( $el == 'item' or $el == 'entry' )
274
+        if ($el == 'item' or $el == 'entry')
275 275
         {
276 276
             $this->items[] = $this->current_item;
277 277
             $this->current_item = array();
278 278
             $this->initem = false;
279 279
         }
280
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
280
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput')
281 281
         {
282 282
             $this->intextinput = false;
283 283
         }
284
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
284
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image')
285 285
         {
286 286
             $this->inimage = false;
287 287
         }
288
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
288
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
289 289
         {
290 290
             $this->incontent = false;
291 291
         }
292
-        elseif ($el == 'channel' or $el == 'feed' )
292
+        elseif ($el == 'channel' or $el == 'feed')
293 293
         {
294 294
             $this->inchannel = false;
295 295
         }
296
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
296
+        elseif ($this->feed_type == ATOM and $this->incontent) {
297 297
             // balance tags properly
298 298
             // note:  i don't think this is actually neccessary
299
-            if ( $this->stack[0] == $el )
299
+            if ($this->stack[0] == $el)
300 300
             {
301 301
                 $this->append_content("</$el>");
302 302
             }
@@ -304,91 +304,91 @@  discard block
 block discarded – undo
304 304
                 $this->append_content("<$el />");
305 305
             }
306 306
 
307
-            array_shift( $this->stack );
307
+            array_shift($this->stack);
308 308
         }
309 309
         else {
310
-            array_shift( $this->stack );
310
+            array_shift($this->stack);
311 311
         }
312 312
 
313 313
         $this->current_namespace = false;
314 314
     }
315 315
 
316
-    function concat (&$str1, $str2="") {
317
-        if (!isset($str1) ) {
318
-            $str1="";
316
+    function concat(&$str1, $str2 = ""){
317
+        if (!isset($str1)) {
318
+            $str1 = "";
319 319
         }
320 320
         $str1 .= $str2;
321 321
     }
322 322
 
323 323
 
324 324
 
325
-    function append_content($text) {
326
-        if ( $this->initem ) {
327
-            $this->concat( $this->current_item[ $this->incontent ], $text );
325
+    function append_content($text){
326
+        if ($this->initem) {
327
+            $this->concat($this->current_item[$this->incontent], $text);
328 328
         }
329
-        elseif ( $this->inchannel ) {
330
-            $this->concat( $this->channel[ $this->incontent ], $text );
329
+        elseif ($this->inchannel) {
330
+            $this->concat($this->channel[$this->incontent], $text);
331 331
         }
332 332
     }
333 333
 
334 334
     // smart append - field and namespace aware
335
-    function append($el, $text) {
335
+    function append($el, $text){
336 336
         if (!$el) {
337 337
             return;
338 338
         }
339
-        if ( $this->current_namespace )
339
+        if ($this->current_namespace)
340 340
         {
341
-            if ( $this->initem ) {
341
+            if ($this->initem) {
342 342
                 $this->concat(
343
-                    $this->current_item[ $this->current_namespace ][ $el ], $text);
343
+                    $this->current_item[$this->current_namespace][$el], $text);
344 344
             }
345 345
             elseif ($this->inchannel) {
346 346
                 $this->concat(
347
-                    $this->channel[ $this->current_namespace][ $el ], $text );
347
+                    $this->channel[$this->current_namespace][$el], $text );
348 348
             }
349 349
             elseif ($this->intextinput) {
350 350
                 $this->concat(
351
-                    $this->textinput[ $this->current_namespace][ $el ], $text );
351
+                    $this->textinput[$this->current_namespace][$el], $text );
352 352
             }
353 353
             elseif ($this->inimage) {
354 354
                 $this->concat(
355
-                    $this->image[ $this->current_namespace ][ $el ], $text );
355
+                    $this->image[$this->current_namespace][$el], $text );
356 356
             }
357 357
         }
358 358
         else {
359
-            if ( $this->initem ) {
359
+            if ($this->initem) {
360 360
                 $this->concat(
361
-                    $this->current_item[ $el ], $text);
361
+                    $this->current_item[$el], $text);
362 362
             }
363 363
             elseif ($this->intextinput) {
364 364
                 $this->concat(
365
-                    $this->textinput[ $el ], $text );
365
+                    $this->textinput[$el], $text );
366 366
             }
367 367
             elseif ($this->inimage) {
368 368
                 $this->concat(
369
-                    $this->image[ $el ], $text );
369
+                    $this->image[$el], $text );
370 370
             }
371 371
             elseif ($this->inchannel) {
372 372
                 $this->concat(
373
-                    $this->channel[ $el ], $text );
373
+                    $this->channel[$el], $text );
374 374
             }
375 375
 
376 376
         }
377 377
     }
378 378
 
379
-    function normalize () {
379
+    function normalize(){
380 380
         // if atom populate rss fields
381
-        if ( $this->is_atom() ) {
381
+        if ($this->is_atom()) {
382 382
             $this->channel['description'] = $this->channel['tagline'];
383
-            for ( $i = 0; $i < count($this->items); $i++) {
383
+            for ($i = 0; $i < count($this->items); $i++) {
384 384
                 $item = $this->items[$i];
385
-                if ( isset($item['summary']) )
385
+                if (isset($item['summary']))
386 386
                     $item['description'] = $item['summary'];
387
-                if ( isset($item['atom_content']))
387
+                if (isset($item['atom_content']))
388 388
                     $item['content']['encoded'] = $item['atom_content'];
389 389
 
390
-                $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
391
-                if ( $atom_date ) {
390
+                $atom_date = (isset($item['issued'])) ? $item['issued'] : $item['modified'];
391
+                if ($atom_date) {
392 392
                     $epoch = @parse_w3cdtf($atom_date);
393 393
                     if ($epoch and $epoch > 0) {
394 394
                         $item['date_timestamp'] = $epoch;
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
                 $this->items[$i] = $item;
399 399
             }
400 400
         }
401
-        elseif ( $this->is_rss() ) {
401
+        elseif ($this->is_rss()) {
402 402
             $this->channel['tagline'] = $this->channel['description'];
403
-            for ( $i = 0; $i < count($this->items); $i++) {
403
+            for ($i = 0; $i < count($this->items); $i++) {
404 404
                 $item = $this->items[$i];
405
-                if ( isset($item['description']))
405
+                if (isset($item['description']))
406 406
                     $item['summary'] = $item['description'];
407
-                if ( isset($item['content']['encoded'] ) )
407
+                if (isset($item['content']['encoded']))
408 408
                     $item['atom_content'] = $item['content']['encoded'];
409 409
 
410
-                if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
410
+                if ($this->is_rss() == '1.0' and isset($item['dc']['date'])) {
411 411
                     $epoch = @parse_w3cdtf($item['dc']['date']);
412 412
                     if ($epoch and $epoch > 0) {
413 413
                         $item['date_timestamp'] = $epoch;
414 414
                     }
415 415
                 }
416
-                elseif ( isset($item['pubdate']) ) {
416
+                elseif (isset($item['pubdate'])) {
417 417
                     $epoch = @strtotime($item['pubdate']);
418 418
                     if ($epoch > 0) {
419 419
                         $item['date_timestamp'] = $epoch;
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     }
427 427
 
428 428
 
429
-    function is_rss () {
430
-        if ( $this->feed_type == RSS ) {
429
+    function is_rss(){
430
+        if ($this->feed_type == RSS) {
431 431
             return $this->feed_version;
432 432
         }
433 433
         else {
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
         }
436 436
     }
437 437
 
438
-    function is_atom() {
439
-        if ( $this->feed_type == ATOM ) {
438
+    function is_atom(){
439
+        if ($this->feed_type == ATOM) {
440 440
             return $this->feed_version;
441 441
         }
442 442
         else {
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
     * return XML parser, and possibly re-encoded source
449 449
     *
450 450
     */
451
-    function create_parser($source, $out_enc, $in_enc, $detect) {
452
-        if ( substr(phpversion(),0,1) == 5) {
451
+    function create_parser($source, $out_enc, $in_enc, $detect){
452
+        if (substr(phpversion(), 0, 1) == 5) {
453 453
             $parser = $this->php5_create_parser($in_enc, $detect);
454 454
         }
455 455
         else {
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
     * All hail libxml2!
473 473
     *
474 474
     */
475
-    function php5_create_parser($in_enc, $detect) {
475
+    function php5_create_parser($in_enc, $detect){
476 476
         // by default php5 does a fine job of detecting input encodings
477
-        if(!$detect && $in_enc) {
477
+        if (!$detect && $in_enc) {
478 478
             return xml_parser_create($in_enc);
479 479
         }
480 480
         else {
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
     * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
498 498
     *
499 499
     */
500
-    function php4_create_parser($source, $in_enc, $detect) {
501
-        if ( !$detect ) {
500
+    function php4_create_parser($source, $in_enc, $detect){
501
+        if (!$detect) {
502 502
             return array(xml_parser_create($in_enc), $source);
503 503
         }
504 504
 
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
         // cast the XML to a known encoding
523 523
         // @see http://php.net/iconv
524 524
 
525
-        if (function_exists('iconv'))  {
526
-            $encoded_source = iconv($in_enc,'UTF-8', $source);
525
+        if (function_exists('iconv')) {
526
+            $encoded_source = iconv($in_enc, 'UTF-8', $source);
527 527
             if ($encoded_source) {
528 528
                 return array(xml_parser_create('UTF-8'), $encoded_source);
529 529
             }
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
 
532 532
         // iconv didn't work, try mb_convert_encoding
533 533
         // @see http://php.net/mbstring
534
-        if(function_exists('mb_convert_encoding')) {
535
-            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );
534
+        if (function_exists('mb_convert_encoding')) {
535
+            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
536 536
             if ($encoded_source) {
537 537
                 return array(xml_parser_create('UTF-8'), $encoded_source);
538 538
             }
539 539
         }
540 540
 
541 541
         // else
542
-        $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
542
+        $this->error("Feed is in an unsupported character encoding. ($in_enc) ".
543 543
                      "You may see strange artifacts, and mangled characters.",
544 544
                      E_USER_NOTICE);
545 545
 
546 546
         return array(xml_parser_create(), $source);
547 547
     }
548 548
 
549
-    function known_encoding($enc) {
549
+    function known_encoding($enc){
550 550
         $enc = strtoupper($enc);
551
-        if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
551
+        if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
552 552
             return $enc;
553 553
         }
554 554
         else {
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
         }
557 557
     }
558 558
 
559
-    function error ($errormsg, $lvl=E_USER_WARNING) {
559
+    function error($errormsg, $lvl = E_USER_WARNING){
560 560
         // append PHP's error message if track_errors enabled
561
-        if ( isset($php_errormsg) ) {
561
+        if (isset($php_errormsg)) {
562 562
             $errormsg .= " ($php_errormsg)";
563 563
         }
564
-        if ( MAGPIE_DEBUG ) {
565
-            trigger_error( $errormsg, $lvl);
564
+        if (MAGPIE_DEBUG) {
565
+            trigger_error($errormsg, $lvl);
566 566
         }
567 567
         else {
568
-            error_log( $errormsg, 0);
568
+            error_log($errormsg, 0);
569 569
         }
570 570
 
571
-        $notices = E_USER_NOTICE|E_NOTICE;
572
-        if ( $lvl&$notices ) {
571
+        $notices = E_USER_NOTICE | E_NOTICE;
572
+        if ($lvl & $notices) {
573 573
             $this->WARNING = $errormsg;
574 574
         } else {
575 575
             $this->ERROR = $errormsg;
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 
580 580
 } // end class RSS
581 581
 
582
-function map_attrs($k, $v) {
582
+function map_attrs($k, $v){
583 583
     return "$k=\"$v\"";
584 584
 }
585 585
 
@@ -591,19 +591,19 @@  discard block
 block discarded – undo
591 591
 	define('CASE_LOWER', 0);
592 592
 
593 593
 
594
-	function array_change_key_case($array, $case=CASE_LOWER) {
594
+	function array_change_key_case($array, $case = CASE_LOWER){
595 595
         $output = array();
596
-        switch($case){
596
+        switch ($case) {
597 597
            case CASE_LOWER:
598
-               $cmd='strtolower';
598
+               $cmd = 'strtolower';
599 599
                break;
600 600
            case CASE_UPPER:
601
-               $cmd='strtoupper';
601
+               $cmd = 'strtoupper';
602 602
                break;
603 603
            default:
604 604
                $cmd = '';
605 605
         }
606
-        foreach($array as $key=>$value) {
606
+        foreach ($array as $key=>$value) {
607 607
             $output[empty($cmd) ? $key : $cmd($key)] = $value;
608 608
         }
609 609
         return $output;
Please login to merge, or discard this patch.
manager/media/rss/rss_cache.inc 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,27 +16,27 @@  discard block
 block discarded – undo
16 16
  *
17 17
  */
18 18
 
19
-class RSSCache {
20
-    var $BASE_CACHE = './cache';    // where the cache files are stored
21
-    var $MAX_AGE    = 3600;         // when are files stale, default one hour
22
-    var $ERROR      = "";           // accumulate error messages
19
+class RSSCache{
20
+    var $BASE_CACHE = './cache'; // where the cache files are stored
21
+    var $MAX_AGE    = 3600; // when are files stale, default one hour
22
+    var $ERROR      = ""; // accumulate error messages
23 23
 
24
-    function __construct($base='', $age='') {
25
-        if ( $base ) {
24
+    function __construct($base = '', $age = ''){
25
+        if ($base) {
26 26
             $this->BASE_CACHE = $base;
27 27
         }
28
-        if ( $age ) {
28
+        if ($age) {
29 29
             $this->MAX_AGE = $age;
30 30
         }
31 31
 
32 32
         // attempt to make the cache directory
33
-        if ( ! file_exists( $this->BASE_CACHE ) ) {
34
-            $status = @mkdir( $this->BASE_CACHE, 0755 );
33
+        if (!file_exists($this->BASE_CACHE)) {
34
+            $status = @mkdir($this->BASE_CACHE, 0755);
35 35
 
36 36
             // if make failed
37
-            if ( ! $status ) {
37
+            if (!$status) {
38 38
                 $this->error(
39
-                    "Cache couldn't make dir '" . $this->BASE_CACHE . "'."
39
+                    "Cache couldn't make dir '".$this->BASE_CACHE."'."
40 40
                 );
41 41
             }
42 42
         }
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     Input:      url from wich the rss file was fetched
49 49
     Output:     true on sucess
50 50
 \*=======================================================================*/
51
-    function set ($url, $rss) {
51
+    function set($url, $rss){
52 52
         $this->ERROR = "";
53
-        $cache_file = $this->file_name( $url );
54
-        $fp = @fopen( $cache_file, 'w' );
53
+        $cache_file = $this->file_name($url);
54
+        $fp = @fopen($cache_file, 'w');
55 55
 
56
-        if ( ! $fp ) {
56
+        if (!$fp) {
57 57
             $this->error(
58 58
                 "Cache unable to open file for writing: $cache_file"
59 59
             );
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
 
63 63
 
64
-        $data = $this->serialize( $rss );
65
-        fwrite( $fp, $data );
66
-        fclose( $fp );
64
+        $data = $this->serialize($rss);
65
+        fwrite($fp, $data);
66
+        fclose($fp);
67 67
 
68 68
         return $cache_file;
69 69
     }
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
     Input:      url from wich the rss file was fetched
75 75
     Output:     cached object on HIT, false on MISS
76 76
 \*=======================================================================*/
77
-    function get ($url) {
77
+    function get($url){
78 78
         $this->ERROR = "";
79
-        $cache_file = $this->file_name( $url );
79
+        $cache_file = $this->file_name($url);
80 80
 
81
-        if ( ! file_exists( $cache_file ) ) {
81
+        if (!file_exists($cache_file)) {
82 82
             $this->debug(
83 83
                 "Cache doesn't contain: $url (cache file: $cache_file)"
84 84
             );
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $fp = @fopen($cache_file, 'r');
89
-        if ( ! $fp ) {
89
+        if (!$fp) {
90 90
             $this->error(
91 91
                 "Failed to open cache file for reading: $cache_file"
92 92
             );
93 93
             return 0;
94 94
         }
95 95
 
96
-        if ($filesize = filesize($cache_file) ) {
97
-        	$data = fread( $fp, filesize($cache_file) );
98
-        	$rss = $this->unserialize( $data );
96
+        if ($filesize = filesize($cache_file)) {
97
+        	$data = fread($fp, filesize($cache_file));
98
+        	$rss = $this->unserialize($data);
99 99
 
100 100
         	return $rss;
101 101
     	}
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
     Input:      url from wich the rss file was fetched
111 111
     Output:     cached object on HIT, false on MISS
112 112
 \*=======================================================================*/
113
-    function check_cache ( $url ) {
113
+    function check_cache($url){
114 114
         $this->ERROR = "";
115
-        $filename = $this->file_name( $url );
115
+        $filename = $this->file_name($url);
116 116
 
117
-        if ( file_exists( $filename ) ) {
117
+        if (file_exists($filename)) {
118 118
             // find how long ago the file was added to the cache
119 119
             // and whether that is longer then MAX_AGE
120
-            $mtime = filemtime( $filename );
120
+            $mtime = filemtime($filename);
121 121
             $age = time() - $mtime;
122
-            if ( $this->MAX_AGE > $age ) {
122
+            if ($this->MAX_AGE > $age) {
123 123
                 // object exists and is current
124 124
                 return 'HIT';
125 125
             }
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
         }
135 135
     }
136 136
 
137
-	function cache_age( $cache_key ) {
138
-		$filename = $this->file_name( $url );
139
-		if ( file_exists( $filename ) ) {
140
-			$mtime = filemtime( $filename );
137
+	function cache_age($cache_key){
138
+		$filename = $this->file_name($url);
139
+		if (file_exists($filename)) {
140
+			$mtime = filemtime($filename);
141 141
             $age = time() - $mtime;
142 142
 			return $age;
143 143
 		}
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 /*=======================================================================*\
150 150
     Function:   serialize
151 151
 \*=======================================================================*/
152
-    function serialize ( $rss ) {
153
-        return serialize( $rss );
152
+    function serialize($rss){
153
+        return serialize($rss);
154 154
     }
155 155
 
156 156
 /*=======================================================================*\
157 157
     Function:   unserialize
158 158
 \*=======================================================================*/
159
-    function unserialize ( $data ) {
160
-        return unserialize( $data );
159
+    function unserialize($data){
160
+        return unserialize($data);
161 161
     }
162 162
 
163 163
 /*=======================================================================*\
@@ -166,31 +166,31 @@  discard block
 block discarded – undo
166 166
     Input:      url from wich the rss file was fetched
167 167
     Output:     a file name
168 168
 \*=======================================================================*/
169
-    function file_name ($url) {
170
-        $filename = md5( $url );
171
-        return implode( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
169
+    function file_name($url){
170
+        $filename = md5($url);
171
+        return implode(DIRECTORY_SEPARATOR, array($this->BASE_CACHE, $filename));
172 172
     }
173 173
 
174 174
 /*=======================================================================*\
175 175
     Function:   error
176 176
     Purpose:    register error
177 177
 \*=======================================================================*/
178
-    function error ($errormsg, $lvl=E_USER_WARNING) {
178
+    function error($errormsg, $lvl = E_USER_WARNING){
179 179
         // append PHP's error message if track_errors enabled
180
-        if ( isset($php_errormsg) ) {
180
+        if (isset($php_errormsg)) {
181 181
             $errormsg .= " ($php_errormsg)";
182 182
         }
183 183
         $this->ERROR = $errormsg;
184
-        if ( MAGPIE_DEBUG ) {
185
-            trigger_error( $errormsg, $lvl);
184
+        if (MAGPIE_DEBUG) {
185
+            trigger_error($errormsg, $lvl);
186 186
         }
187 187
         else {
188
-            error_log( $errormsg, 0);
188
+            error_log($errormsg, 0);
189 189
         }
190 190
     }
191 191
 
192
-    function debug ($debugmsg, $lvl=E_USER_NOTICE) {
193
-        if ( MAGPIE_DEBUG ) {
192
+    function debug($debugmsg, $lvl = E_USER_NOTICE){
193
+        if (MAGPIE_DEBUG) {
194 194
             $this->error("MagpieRSS [debug] $debugmsg", $lvl);
195 195
         }
196 196
     }
Please login to merge, or discard this patch.
manager/processors/save_plugin.processor.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
4 4
 }
5 5
 if (!$modx->hasPermission('save_plugin')) {
6 6
     $modx->webAlertAndQuit($_lang['error_no_privileges']);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $name = $modx->db->escape(trim($_POST['name']));
11 11
 $description = $modx->db->escape($_POST['description']);
12 12
 $locked = $_POST['locked'] == 'on' ? '1' : '0';
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 
21 21
 //Kyle Jaebker - added category support
22 22
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
23
-    $categoryid = (int)$_POST['categoryid'];
23
+    $categoryid = (int) $_POST['categoryid'];
24 24
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
25 25
     $categoryid = 0;
26 26
 } else {
27
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
27
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
28 28
     $categoryid = getCategory($_POST['newcategory']);
29 29
 }
30 30
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
     $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid;
41 41
 
42 42
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
43
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
43
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
44 44
     if ($version) {
45
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
45
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
46 46
     }
47 47
     if (isset($parsed['modx_category'])) {
48
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
48
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
49 49
         $categoryid = getCategory($parsed['modx_category']);
50 50
     }
51 51
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         // finished emptying cache - redirect
104 104
         if ($_POST['stay'] != '') {
105 105
             $a = ($_POST['stay'] == '2') ? "102&id=$newid" : '101';
106
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
106
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
107 107
             header($header);
108 108
         } else {
109 109
             $header = 'Location: index.php?a=76&r=2';
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // finished emptying cache - redirect
159 159
         if ($_POST['stay'] != '') {
160 160
             $a = ($_POST['stay'] == '2') ? "102&id=$id" : '101';
161
-            $header = 'Location: index.php?a=' . $a . '&r=2&stay=' . $_POST['stay'];
161
+            $header = 'Location: index.php?a='.$a.'&r=2&stay='.$_POST['stay'];
162 162
             header($header);
163 163
         } else {
164 164
             $modx->unlockElement(5, $id);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     // save selected system events
178 178
     $formEventList = array();
179 179
     foreach ($sysevents as $evtId) {
180
-        if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId);
180
+        if (!preg_match('@^[1-9][0-9]*$@', $evtId)) $evtId = getEventIdByName($evtId);
181 181
         if ($mode == '101') {
182 182
             $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'");
183 183
         } else {
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
     $rs = $modx->db->select('*', '[+prefix+]site_plugin_events', sprintf("pluginid='%s'", $id));
203 203
     $dbEventList = array();
204 204
     $del = array();
205
-    while($row = $modx->db->getRow($rs)) {
206
-        if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
205
+    while ($row = $modx->db->getRow($rs)) {
206
+        if (!in_array($row['evtid'], $evtids)) $del[] = $row['evtid'];
207 207
     }
208 208
 
209
-    if(empty($del)) return;
209
+    if (empty($del)) return;
210 210
 
211
-    foreach($del as $delid) {
211
+    foreach ($del as $delid) {
212 212
         $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id));
213 213
     }
214 214
 }
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 function getEventIdByName($name)
217 217
 {
218 218
     global $modx;
219
-    static $eventIds=array();
219
+    static $eventIds = array();
220 220
 
221
-    if(isset($eventIds[$name])) return $eventIds[$name];
221
+    if (isset($eventIds[$name])) return $eventIds[$name];
222 222
 
223 223
     $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames');
224 224
     while ($row = $modx->db->getRow($rs)) {
Please login to merge, or discard this patch.
manager/includes/veriword.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $modx->getSettings();
6 6
 $modx->invokeEvent('OnWebPageInit');
7 7
 
8
-$vword = new VeriWord(148,60);
8
+$vword = new VeriWord(148, 60);
9 9
 $vword->output_image();
10 10
 $vword->destroy_image();
11 11
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 ## see sample.php for test and usage
42 42
 ## sample URL: http://www.program-ruti.org/veriword/
43 43
 ####
44
-class VeriWord {
44
+class VeriWord{
45 45
 
46 46
     /* path to font directory*/
47 47
     public $dir_font   = "ttf/";
@@ -52,44 +52,44 @@  discard block
 block discarded – undo
52 52
     public $im_height  = 0;
53 53
     public $im;
54 54
 
55
-    public function __construct($w=200, $h=80) {
55
+    public function __construct($w = 200, $h = 80){
56 56
         /* create session to set word for verification */
57 57
         $this->set_veriword();
58
-        $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font;
58
+        $this->dir_font = dirname(__FILE__).'/'.$this->dir_font;
59 59
         $this->im_width         = $w;
60 60
         $this->im_height        = $h;
61 61
     }
62 62
 
63
-    public function set_veriword() {
63
+    public function set_veriword(){
64 64
         /* create session variable for verification,
65 65
            you may change the session variable name */
66 66
         $this->word             = $this->pick_word();
67 67
         $_SESSION['veriword']   = $this->word;
68 68
     }
69 69
 
70
-    public function output_image() {
70
+    public function output_image(){
71 71
         /* output the image as jpeg */
72 72
         $this->draw_image();
73 73
         header("Content-type: image/jpeg");
74 74
         imagejpeg($this->im);
75 75
     }
76 76
 
77
-    public function pick_word() {
77
+    public function pick_word(){
78 78
         global $modx;
79 79
         // set default words
80
-        $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
80
+        $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote";
81 81
         $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words;
82 82
         $arr_words = array_filter(array_map('trim', explode(',', $words)));
83 83
 
84 84
         /* pick one randomly for text verification */
85
-        return (string) $arr_words[array_rand($arr_words)].rand(10,999);
85
+        return (string) $arr_words[array_rand($arr_words)].rand(10, 999);
86 86
     }
87 87
 
88
-    public function draw_text() {
88
+    public function draw_text(){
89 89
         $dir = dir($this->dir_font);
90 90
         $fontstmp = array();
91 91
         while (false !== ($file = $dir->read())) {
92
-            if(substr($file, -4) == '.ttf') {
92
+            if (substr($file, -4) == '.ttf') {
93 93
                 $fontstmp[] = $this->dir_font.$file;
94 94
             }
95 95
         }
@@ -97,35 +97,35 @@  discard block
 block discarded – undo
97 97
         $text_font = (string) $fontstmp[array_rand($fontstmp)];
98 98
 
99 99
         /* angle for text inclination */
100
-        $text_angle = rand(-9,9);
100
+        $text_angle = rand(-9, 9);
101 101
         /* initial text size */
102 102
         $text_size  = 30;
103 103
         /* calculate text width and height */
104
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
105
-        $text_width = $box[2]-$box[0]; //text width
106
-        $text_height= $box[5]-$box[3]; //text height
104
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
105
+        $text_width = $box[2] - $box[0]; //text width
106
+        $text_height = $box[5] - $box[3]; //text height
107 107
 
108 108
         /* adjust text size */
109
-        $text_size  = round((20 * $this->im_width)/$text_width);
109
+        $text_size  = round((20 * $this->im_width) / $text_width);
110 110
 
111 111
         /* recalculate text width and height */
112
-        $box        = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);
113
-        $text_width = $box[2]-$box[0]; //text width
114
-        $text_height= $box[5]-$box[3]; //text height
112
+        $box        = imagettfbbox($text_size, $text_angle, $text_font, $this->word);
113
+        $text_width = $box[2] - $box[0]; //text width
114
+        $text_height = $box[5] - $box[3]; //text height
115 115
 
116 116
         /* calculate center position of text */
117
-        $text_x         = ($this->im_width - $text_width)/2;
118
-        $text_y         = ($this->im_height - $text_height)/2;
117
+        $text_x         = ($this->im_width - $text_width) / 2;
118
+        $text_y         = ($this->im_height - $text_height) / 2;
119 119
 
120 120
         /* create canvas for text drawing */
121
-        $im_text        = imagecreate ($this->im_width, $this->im_height);
122
-        $bg_color       = imagecolorallocate ($im_text, 255, 255, 255);
121
+        $im_text        = imagecreate($this->im_width, $this->im_height);
122
+        $bg_color       = imagecolorallocate($im_text, 255, 255, 255);
123 123
 
124 124
         /* pick color for text */
125
-        $text_color     = imagecolorallocate ($im_text, 0, 51, 153);
125
+        $text_color     = imagecolorallocate($im_text, 0, 51, 153);
126 126
 
127 127
         /* draw text into canvas */
128
-        imagettftext    (   $im_text,
128
+        imagettftext($im_text,
129 129
             $text_size,
130 130
             $text_angle,
131 131
             $text_x,
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
 
143
-    public function draw_image() {
143
+    public function draw_image(){
144 144
 
145 145
         /* pick one background image randomly from image directory */
146
-        $img_file       = $this->dir_noise."noise".rand(1,4).".jpg";
146
+        $img_file       = $this->dir_noise."noise".rand(1, 4).".jpg";
147 147
 
148 148
         /* create "noise" background image from your image stock*/
149
-        $noise_img      = @imagecreatefromjpeg ($img_file);
149
+        $noise_img      = @imagecreatefromjpeg($img_file);
150 150
         $noise_width    = imagesx($noise_img);
151 151
         $noise_height   = imagesy($noise_img);
152 152
 
153 153
         /* resize the background image to fit the size of image output */
154
-        $this->im       = imagecreatetruecolor($this->im_width,$this->im_height);
155
-        imagecopyresampled ($this->im,
154
+        $this->im       = imagecreatetruecolor($this->im_width, $this->im_height);
155
+        imagecopyresampled($this->im,
156 156
             $noise_img,
157 157
             0, 0, 0, 0,
158 158
             $this->im_width,
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
             $noise_height);
162 162
 
163 163
         /* put text image into background image */
164
-        imagecopymerge (    $this->im,
164
+        imagecopymerge($this->im,
165 165
             $this->draw_text(),
166 166
             0, 0, 0, 0,
167 167
             $this->im_width,
168 168
             $this->im_height,
169
-            70 );
169
+            70);
170 170
 
171 171
         return $this->im;
172 172
     }
173 173
 
174
-    public function destroy_image() {
174
+    public function destroy_image(){
175 175
 
176 176
         imagedestroy($this->im);
177 177
 
Please login to merge, or discard this patch.
install/functions.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! function_exists('install_sessionCheck')) {
2
+if (!function_exists('install_sessionCheck')) {
3 3
     function install_sessionCheck()
4 4
     {
5 5
         global $_lang;
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 </head>
22 22
 <body>
23 23
 	<div class="install">
24
-		<p>' . $_lang["session_problem"] . '</p>
25
-		<p><a href="./">' . $_lang["session_problem_try_again"] . '</a></p>
24
+		<p>' . $_lang["session_problem"].'</p>
25
+		<p><a href="./">' . $_lang["session_problem_try_again"].'</a></p>
26 26
 	</div>
27 27
 </body>
28 28
 </html>';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     }
33 33
 }
34 34
 
35
-if( ! function_exists('parse')) {
35
+if (!function_exists('parse')) {
36 36
     /**
37 37
      * @param string $src
38 38
      * @param array $ph
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     function parse($src, $ph, $left = '[+', $right = '+]')
44 44
     {
45 45
         foreach ($ph as $k => $v) {
46
-            $k = $left . $k . $right;
46
+            $k = $left.$k.$right;
47 47
             $src = str_replace($k, $v, $src);
48 48
         }
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
 }
53 53
 
54
-if( ! function_exists('ph')) {
54
+if (!function_exists('ph')) {
55 55
     /**
56 56
      * @return array
57 57
      */
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $ph['textdir'] = $modx_textdir ? ' id="rtl"' : '';
71 71
         $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd'];
72 72
         $ph['version'] = $moduleVersion;
73
-        $ph['release_date'] = ($modx_textdir ? '&rlm;' : '') . $modx_release_date;
73
+        $ph['release_date'] = ($modx_textdir ? '&rlm;' : '').$modx_release_date;
74 74
         $ph['footer1'] = $_lang['modx_footer1'];
75 75
         $ph['footer2'] = $_lang['modx_footer2'];
76 76
         $ph['current_year'] = date('Y');
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     }
80 80
 }
81 81
 
82
-if( ! function_exists('get_installmode')) {
82
+if (!function_exists('get_installmode')) {
83 83
     /**
84 84
      * @return int
85 85
      */
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     }
142 142
 }
143 143
 
144
-if( ! function_exists('getLangs')) {
144
+if (!function_exists('getLangs')) {
145 145
     /**
146 146
      * @param string $install_language
147 147
      * @return string
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         }
156 156
 
157 157
         $langs = array();
158
-        if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) {
158
+        if ($handle = opendir("../".MGR_DIR."/includes/lang")) {
159 159
             while (false !== ($file = readdir($handle))) {
160 160
                 if (strpos($file, '.inc.') !== false) {
161 161
                     $langs[] = $file;
Please login to merge, or discard this patch.
install/actions/action_options.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
2
+$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0;
3 3
 
4
-if( ! function_exists('getTemplates')) {
4
+if (!function_exists('getTemplates')) {
5 5
     /**
6 6
      * @param array $presets
7 7
      * @return string
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
             $_[] = parse($tpl, $ph);
26 26
             $i++;
27 27
         }
28
-        return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : '';
28
+        return (0 < count($_)) ? '<h3>[%templates%]</h3>'.implode("\n", $_) : '';
29 29
     }
30 30
 }
31 31
 
32
-if( ! function_exists('getTVs')) {
32
+if (!function_exists('getTVs')) {
33 33
     /**
34 34
      * @param array $presets
35 35
      * @return string
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
             $_[] = parse($tpl, $ph);
55 55
             $i++;
56 56
         }
57
-        return (0 < count($_)) ? '<h3>[%tvs%]</h3>' . implode("\n", $_) : '';
57
+        return (0 < count($_)) ? '<h3>[%tvs%]</h3>'.implode("\n", $_) : '';
58 58
     }
59 59
 }
60 60
 
61
-if( ! function_exists('getChunks')) {
61
+if (!function_exists('getChunks')) {
62 62
     /**
63 63
      * display chunks
64 64
      *
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
             $_[] = parse($tpl, $ph);
85 85
             $i++;
86 86
         }
87
-        return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : '';
87
+        return (0 < count($_)) ? '<h3>[%chunks%]</h3>'.implode("\n", $_) : '';
88 88
     }
89 89
 }
90 90
 
91
-if( ! function_exists('getModules')) {
91
+if (!function_exists('getModules')) {
92 92
     /**
93 93
      * display modules
94 94
      *
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
             $_[] = parse($tpl, $ph);
115 115
             $i++;
116 116
         }
117
-        return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : '';
117
+        return (0 < count($_)) ? '<h3>[%modules%]</h3>'.implode("\n", $_) : '';
118 118
     }
119 119
 }
120 120
 
121
-if( ! function_exists('getPlugins')) {
121
+if (!function_exists('getPlugins')) {
122 122
     /**
123 123
      * display plugins
124 124
      *
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             $_[] = parse($tpl, $ph);
149 149
             $i++;
150 150
         }
151
-        return (0 < count($_)) ? '<h3>[%plugins%]</h3>' . implode("\n", $_) : '';
151
+        return (0 < count($_)) ? '<h3>[%plugins%]</h3>'.implode("\n", $_) : '';
152 152
     }
153 153
 }
154 154
 
155
-if( ! function_exists('getSnippets')) {
155
+if (!function_exists('getSnippets')) {
156 156
     /**
157 157
      * display snippets
158 158
      *
@@ -178,23 +178,23 @@  discard block
 block discarded – undo
178 178
             $_[] = parse($tpl, $ph);
179 179
             $i++;
180 180
         }
181
-        return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : '';
181
+        return (0 < count($_)) ? '<h3>[%snippets%]</h3>'.implode("\n", $_) : '';
182 182
     }
183 183
 }
184 184
 
185
-switch($installMode){
185
+switch ($installMode) {
186 186
     case 0:
187 187
     case 2:
188 188
         $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci';
189 189
         $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
190 190
         $_POST['database_connection_charset'] = $database_charset;
191
-        if(empty($_SESSION['databaseloginpassword']))
191
+        if (empty($_SESSION['databaseloginpassword']))
192 192
             $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword'];
193
-        if(empty($_SESSION['databaseloginname']))
193
+        if (empty($_SESSION['databaseloginname']))
194 194
             $_SESSION['databaseloginname'] = $_POST['databaseloginname'];
195 195
         break;
196 196
     case 1:
197
-        include $base_path . MGR_DIR . '/includes/config.inc.php';
197
+        include $base_path.MGR_DIR.'/includes/config.inc.php';
198 198
         if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) {
199 199
             if (@ mysqli_query($conn, "USE {$dbase}")) {
200 200
                 if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : '';
250 250
 
251 251
 # load setup information file
252
-include($base_path . 'install/setup.info.php');
252
+include($base_path.'install/setup.info.php');
253 253
 $ph['templates'] = getTemplates($moduleTemplates);
254 254
 $ph['tvs']       = getTVs($moduleTVs);
255 255
 $ph['chunks']    = getChunks($moduleChunks);
@@ -259,6 +259,6 @@  discard block
 block discarded – undo
259 259
 
260 260
 $ph['action'] = ($installMode == 1) ? 'mode' : 'connection';
261 261
 
262
-$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html');
263
-$content = parse($tpl,$ph);
264
-echo parse($content,$_lang,'[%','%]');
262
+$tpl = file_get_contents($base_path.'install/actions/tpl_options.html');
263
+$content = parse($tpl, $ph);
264
+echo parse($content, $_lang, '[%', '%]');
Please login to merge, or discard this patch.
install/instprocessor.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
3 3
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
4
-}else{
4
+} else {
5 5
     define('MGR_DIR', 'manager');
6 6
 }
7 7
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 echo "<p>{$_lang['setup_database']}</p>\n";
30 30
 
31
-$installMode= (int)$_POST['installmode'];
31
+$installMode = (int) $_POST['installmode'];
32 32
 $installData = $_POST['installdata'] == "1" ? 1 : 0;
33 33
 
34 34
 //if ($installMode == 1) {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
43 43
 $database_connection_charset = $_POST['database_connection_charset'];
44 44
 $database_connection_method = $_POST['database_connection_method'];
45
-$dbase = "`" . $_POST['database_name'] . "`";
45
+$dbase = "`".$_POST['database_name']."`";
46 46
 $table_prefix = $_POST['tableprefix'];
47 47
 $adminname = $_POST['cmsadmin'];
48 48
 $adminemail = $_POST['cmsadminemail'];
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 // set session name variable
55 55
 if (!isset ($site_sessionname)) {
56
-    $site_sessionname = 'SN' . uniqid('');
56
+    $site_sessionname = 'SN'.uniqid('');
57 57
 }
58 58
 
59 59
 // get base path and url
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     array_pop($a);
68 68
 $pth = implode("install", $a);
69 69
 unset ($a);
70
-$base_url = $url . (substr($url, -1) != "/" ? "/" : "");
71
-$base_path = $pth . (substr($pth, -1) != "/" ? "/" : "");
70
+$base_url = $url.(substr($url, -1) != "/" ? "/" : "");
71
+$base_path = $pth.(substr($pth, -1) != "/" ? "/" : "");
72 72
 
73 73
 // connect to the database
74
-echo "<p>". $_lang['setup_database_create_connection'];
74
+echo "<p>".$_lang['setup_database_create_connection'];
75 75
 if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) {
76 76
     echo '<span class="notok">'.$_lang["setup_database_create_connection_failed"]."</span></p><p>".$_lang['setup_database_create_connection_failed_note']."</p>";
77 77
     return;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 }
81 81
 
82 82
 // select database
83
-echo "<p>".$_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: ";
83
+echo "<p>".$_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: ";
84 84
 if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) {
85 85
     echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>";
86 86
     $create = true;
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 // try to create the database
94 94
 if ($create) {
95
-    echo "<p>".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: ";
95
+    echo "<p>".$_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: ";
96 96
     //	if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) {
97
-    if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
97
+    if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
98 98
         echo '<span class="notok">'.$_lang['setup_database_creation_failed']."</span>".$_lang['setup_database_creation_failed_note']."</p>";
99 99
         $errors += 1;
100 100
 ?>
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 // check table prefix
115 115
 if ($installMode == 0) {
116
-    echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: ";
117
-    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
118
-        echo '<span class="notok">' . $_lang['failed'] . "</span>" . $_lang['table_prefix_already_inuse'] . "</p>";
116
+    echo "<p>".$_lang['checking_table_prefix'].$table_prefix."`: ";
117
+    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
118
+        echo '<span class="notok">'.$_lang['failed']."</span>".$_lang['table_prefix_already_inuse']."</p>";
119 119
         $errors += 1;
120
-        echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>";
120
+        echo "<p>".$_lang['table_prefix_already_inuse_note']."</p>";
121 121
         return;
122 122
     } else {
123 123
         echo '<span class="ok">'.$_lang['ok']."</span></p>";
124 124
     }
125 125
 }
126 126
 
127
-if(!function_exists('parseProperties')) {
127
+if (!function_exists('parseProperties')) {
128 128
     /**
129 129
      * parses a resource property string and returns the result as an array
130 130
      * duplicate of method in documentParser class
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
      * @param string $propertyString
133 133
      * @return array
134 134
      */
135
-    function parseProperties($propertyString) {
136
-        $parameter= array ();
135
+    function parseProperties($propertyString){
136
+        $parameter = array();
137 137
         if (!empty ($propertyString)) {
138
-            $tmpParams= explode("&", $propertyString);
138
+            $tmpParams = explode("&", $propertyString);
139 139
             $countParams = count($tmpParams);
140
-            for ($x= 0; $x < $countParams; $x++) {
140
+            for ($x = 0; $x < $countParams; $x++) {
141 141
                 if (strpos($tmpParams[$x], '=', 0)) {
142
-                    $pTmp= explode("=", $tmpParams[$x]);
143
-                    $pvTmp= explode(";", trim($pTmp[1]));
142
+                    $pTmp = explode("=", $tmpParams[$x]);
143
+                    $pvTmp = explode(";", trim($pTmp[1]));
144 144
                     if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
145
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
145
+                        $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default
146 146
                     else
147 147
                         if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
148
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
148
+                            $parameter[trim($pTmp[0])] = $pvTmp[2];
149 149
                 }
150 150
             }
151 151
         }
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 // check status of Inherit Parent Template plugin
157 157
 $auto_template_logic = 'parent';
158 158
 if ($installMode != 0) {
159
-    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'");
159
+    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'");
160 160
     $row = mysqli_fetch_row($rs);
161
-    if(!$row) {
161
+    if (!$row) {
162 162
         // not installed
163 163
         $auto_template_logic = 'system';
164 164
     } else {
165
-        if($row[1] == 1) {
165
+        if ($row[1] == 1) {
166 166
             // installed but disabled
167 167
             $auto_template_logic = 'system';
168 168
         } else {
169 169
             // installed, enabled .. see how it's configured
170 170
             $properties = parseProperties($row[0]);
171
-            if(isset($properties['inheritTemplate'])) {
172
-                if($properties['inheritTemplate'] == 'From First Sibling') {
171
+            if (isset($properties['inheritTemplate'])) {
172
+                if ($properties['inheritTemplate'] == 'From First Sibling') {
173 173
                     $auto_template_logic = 'sibling';
174 174
                 }
175 175
             }
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
 $sqlParser->connect();
194 194
 
195 195
 // install/update database
196
-echo "<p>" . $_lang['setup_database_creating_tables'];
196
+echo "<p>".$_lang['setup_database_creating_tables'];
197 197
 if ($moduleSQLBaseFile) {
198 198
     $sqlParser->process($moduleSQLBaseFile);
199 199
     // display database results
200 200
     if ($sqlParser->installFailed == true) {
201 201
         $errors += 1;
202
-        echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
203
-        echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
204
-        echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
202
+        echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
203
+        echo "<p>".$_lang['setup_couldnt_install']."</p>";
204
+        echo "<p>".$_lang['installation_error_occured']."<br /><br />";
205 205
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
206
-            echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
206
+            echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
207 207
         }
208 208
         echo "</p>";
209
-        echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
209
+        echo "<p>".$_lang['some_tables_not_updated']."</p>";
210 210
         return;
211 211
     } else {
212 212
         echo '<span class="ok">'.$_lang['ok']."</span></p>";
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 // custom or not
217 217
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
218 218
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
219
-}else{
219
+} else {
220 220
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
221 221
 }
222 222
 
223 223
 // write the config.inc.php file if new installation
224
-echo "<p>" . $_lang['writing_config_file'];
224
+echo "<p>".$_lang['writing_config_file'];
225 225
 
226 226
 $confph = array();
227 227
 $confph['database_server']    = $database_server;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 $chmodSuccess = @chmod($filename, 0404);
254 254
 
255 255
 if ($configFileFailed == true) {
256
-    echo '<span class="notok">' . $_lang['failed'] . "</span></p>";
256
+    echo '<span class="notok">'.$_lang['failed']."</span></p>";
257 257
     $errors += 1;
258 258
 ?>
259 259
     <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p>
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
 // generate new site_id and set manager theme to default
271 271
 if ($installMode == 0) {
272 272
     $siteid = uniqid('');
273
-    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
273
+    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
274 274
 } else {
275 275
     // update site_id if missing
276
-    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
276
+    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'");
277 277
     if ($ds) {
278 278
         $r = mysqli_fetch_assoc($ds);
279 279
         $siteid = $r['setting_value'];
280 280
         if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
281 281
             $siteid = uniqid('');
282
-            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
282
+            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
283 283
         }
284 284
     }
285 285
 }
286 286
 
287 287
 // Reset database for installation of demo-site
288 288
 if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) {
289
-	echo "<p>" . $_lang['resetting_database'];
289
+	echo "<p>".$_lang['resetting_database'];
290 290
 	$sqlParser->process($moduleSQLResetFile);
291 291
 	// display database results
292 292
 	if ($sqlParser->installFailed == true) {
293 293
 		$errors += 1;
294
-		echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
295
-		echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
296
-		echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
294
+		echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
295
+		echo "<p>".$_lang['setup_couldnt_install']."</p>";
296
+		echo "<p>".$_lang['installation_error_occured']."<br /><br />";
297 297
 		for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
298
-			echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
298
+			echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
299 299
 		}
300 300
 		echo "</p>";
301
-		echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
301
+		echo "<p>".$_lang['some_tables_not_updated']."</p>";
302 302
 		return;
303 303
 	} else {
304 304
 		echo '<span class="ok">'.$_lang['ok']."</span></p>";
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 
308 308
 // Install Templates
309 309
 if (isset ($_POST['template']) || $installData) {
310
-    echo "<h3>" . $_lang['templates'] . ":</h3> ";
310
+    echo "<h3>".$_lang['templates'].":</h3> ";
311 311
     $selTemplates = $_POST['template'];
312 312
     foreach ($moduleTemplates as $k=>$moduleTemplate) {
313 313
         $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1;
314
-        if($installSample || in_array($k, $selTemplates)) {
314
+        if ($installSample || in_array($k, $selTemplates)) {
315 315
             $name = mysqli_real_escape_string($conn, $moduleTemplate[0]);
316 316
             $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]);
317 317
             $category = mysqli_real_escape_string($conn, $moduleTemplate[4]);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $filecontent = $moduleTemplate[3];
320 320
             $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site
321 321
             if (!file_exists($filecontent)) {
322
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
322
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>";
323 323
             } else {
324 324
                 // Create the category if it does not already exist
325 325
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -329,31 +329,31 @@  discard block
 block discarded – undo
329 329
                 $template = mysqli_real_escape_string($conn, $template);
330 330
 
331 331
                 // See if the template already exists
332
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
332
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'");
333 333
 
334 334
                 if (mysqli_num_rows($rs)) {
335
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
335
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
336 336
                         $errors += 1;
337
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
337
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
338 338
                         return;
339 339
                     }
340
-                    if(!is_null($save_sql_id_as)) {
340
+                    if (!is_null($save_sql_id_as)) {
341 341
                         $sql_id = @mysqli_insert_id($sqlParser->conn);
342
-                        if(!$sql_id) {
343
-                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"));
342
+                        if (!$sql_id) {
343
+                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;"));
344 344
                             $sql_id = $idQuery['id'];
345 345
                         }
346 346
                         $custom_placeholders[$save_sql_id_as] = $sql_id;
347 347
                     }
348
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
348
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
349 349
                 } else {
350
-                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
350
+                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
351 351
                         $errors += 1;
352
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
352
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
353 353
                         return;
354 354
                     }
355
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
356
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
355
+                    if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
356
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
357 357
                 }
358 358
             }
359 359
         }
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 
363 363
 // Install Template Variables
364 364
 if (isset ($_POST['tv']) || $installData) {
365
-    echo "<h3>" . $_lang['tvs'] . ":</h3> ";
365
+    echo "<h3>".$_lang['tvs'].":</h3> ";
366 366
     $selTVs = $_POST['tv'];
367 367
     foreach ($moduleTVs as $k=>$moduleTV) {
368 368
         $installSample = in_array('sample', $moduleTV[12]) && $installData == 1;
369
-        if($installSample || in_array($k, $selTVs)) {
369
+        if ($installSample || in_array($k, $selTVs)) {
370 370
             $name = mysqli_real_escape_string($conn, $moduleTV[0]);
371 371
             $caption = mysqli_real_escape_string($conn, $moduleTV[1]);
372 372
             $desc = mysqli_real_escape_string($conn, $moduleTV[2]);
@@ -384,25 +384,25 @@  discard block
 block discarded – undo
384 384
             // Create the category if it does not already exist
385 385
             $category = getCreateDbCategory($category, $sqlParser);
386 386
 
387
-            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'");
387
+            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'");
388 388
             if (mysqli_num_rows($rs)) {
389 389
                 $insert = true;
390
-                while($row = mysqli_fetch_assoc($rs)) {
391
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
392
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
390
+                while ($row = mysqli_fetch_assoc($rs)) {
391
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
392
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
393 393
                         return;
394 394
                     }
395 395
                     $insert = false;
396 396
                 }
397
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
397
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
398 398
             } else {
399 399
                 //$q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
400
-                $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
400
+                $q = "INSERT INTO $dbase.`".$table_prefix."site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
401 401
                 if (!mysqli_query($sqlParser->conn, $q)) {
402
-                    echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
402
+                    echo "<p>".mysqli_error($sqlParser->conn)."</p>";
403 403
                     return;
404 404
                 }
405
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
405
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
406 406
             }
407 407
 
408 408
             // add template assignments
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
             if (count($assignments) > 0) {
412 412
 
413 413
                 // remove existing tv -> template assignments
414
-                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
414
+                $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
415 415
                 $row = mysqli_fetch_assoc($ds);
416 416
                 $id = $row["id"];
417
-                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
417
+                mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\'');
418 418
 
419 419
                 // add tv -> template assignments
420 420
                 foreach ($assignments as $assignment) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                     if ($ds && $ts) {
424 424
                         $tRow = mysqli_fetch_assoc($ts);
425 425
                         $templateId = $tRow['id'];
426
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
426
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
427 427
                    }
428 428
                 }
429 429
             }
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
 
434 434
 // Install Chunks
435 435
 if (isset ($_POST['chunk']) || $installData) {
436
-    echo "<h3>" . $_lang['chunks'] . ":</h3> ";
436
+    echo "<h3>".$_lang['chunks'].":</h3> ";
437 437
     $selChunks = $_POST['chunk'];
438 438
     foreach ($moduleChunks as $k=>$moduleChunk) {
439 439
         $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1;
440 440
         $count_new_name = 0;
441
-        if($installSample || in_array($k, $selChunks)) {
441
+        if ($installSample || in_array($k, $selChunks)) {
442 442
 
443 443
             $name = mysqli_real_escape_string($conn, $moduleChunk[0]);
444 444
             $desc = mysqli_real_escape_string($conn, $moduleChunk[1]);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             $filecontent = $moduleChunk[2];
448 448
 
449 449
             if (!file_exists($filecontent))
450
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
450
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>";
451 451
             else {
452 452
 
453 453
                 // Create the category if it does not already exist
@@ -455,31 +455,31 @@  discard block
 block discarded – undo
455 455
 
456 456
                 $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1);
457 457
                 $chunk = mysqli_real_escape_string($conn, $chunk);
458
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'");
458
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'");
459 459
                 $count_original_name = mysqli_num_rows($rs);
460
-                if($overwrite == 'false') {
461
-                    $newname = $name . '-' . str_replace('.', '_', $modx_version);
462
-                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'");
460
+                if ($overwrite == 'false') {
461
+                    $newname = $name.'-'.str_replace('.', '_', $modx_version);
462
+                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'");
463 463
                     $count_new_name = mysqli_num_rows($rs);
464 464
                 }
465 465
                 $update = $count_original_name > 0 && $overwrite == 'true';
466 466
                 if ($update) {
467
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
467
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
468 468
                         $errors += 1;
469
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
469
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
470 470
                         return;
471 471
                     }
472
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
473
-                } elseif($count_new_name == 0) {
474
-                    if($count_original_name > 0 && $overwrite == 'false') {
472
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
473
+                } elseif ($count_new_name == 0) {
474
+                    if ($count_original_name > 0 && $overwrite == 'false') {
475 475
                         $name = $newname;
476 476
                     }
477
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
477
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
478 478
                         $errors += 1;
479
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
479
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
480 480
                         return;
481 481
                     }
482
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
482
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
483 483
                 }
484 484
             }
485 485
         }
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 
489 489
 // Install Modules
490 490
 if (isset ($_POST['module']) || $installData) {
491
-    echo "<h3>" . $_lang['modules'] . ":</h3> ";
491
+    echo "<h3>".$_lang['modules'].":</h3> ";
492 492
     $selModules = $_POST['module'];
493 493
     foreach ($moduleModules as $k=>$moduleModule) {
494 494
         $installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
495
-        if($installSample || in_array($k, $selModules)) {
495
+        if ($installSample || in_array($k, $selModules)) {
496 496
             $name = mysqli_real_escape_string($conn, $moduleModule[0]);
497 497
             $desc = mysqli_real_escape_string($conn, $moduleModule[1]);
498 498
             $filecontent = $moduleModule[2];
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
502 502
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
503 503
             if (!file_exists($filecontent))
504
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
504
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>";
505 505
             else {
506 506
 
507 507
                 // Create the category if it does not already exist
@@ -510,22 +510,22 @@  discard block
 block discarded – undo
510 510
                 $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
511 511
                 // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab
512 512
                 $module = mysqli_real_escape_string($conn, $module);
513
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'");
513
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'");
514 514
                 if (mysqli_num_rows($rs)) {
515 515
                     $row = mysqli_fetch_assoc($rs);
516
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
517
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
518
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
516
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
517
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
518
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
519 519
                         return;
520 520
                     }
521
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
521
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
522 522
                 } else {
523 523
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
524
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
525
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
524
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
525
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
526 526
                         return;
527 527
                     }
528
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
528
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
529 529
                 }
530 530
             }
531 531
         }
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 
535 535
 // Install Plugins
536 536
 if (isset ($_POST['plugin']) || $installData) {
537
-    echo "<h3>" . $_lang['plugins'] . ":</h3> ";
537
+    echo "<h3>".$_lang['plugins'].":</h3> ";
538 538
     $selPlugs = $_POST['plugin'];
539 539
     foreach ($modulePlugins as $k=>$modulePlugin) {
540 540
         $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1;
541
-        if($installSample || in_array($k, $selPlugs)) {
541
+        if ($installSample || in_array($k, $selPlugs)) {
542 542
             $name = mysqli_real_escape_string($conn, $modulePlugin[0]);
543 543
             $desc = mysqli_real_escape_string($conn, $modulePlugin[1]);
544 544
             $filecontent = $modulePlugin[2];
@@ -548,17 +548,17 @@  discard block
 block discarded – undo
548 548
             $category = mysqli_real_escape_string($conn, $modulePlugin[6]);
549 549
             $leg_names = '';
550 550
             $disabled = $modulePlugin[9];
551
-            if(array_key_exists(7, $modulePlugin)) {
551
+            if (array_key_exists(7, $modulePlugin)) {
552 552
                 // parse comma-separated legacy names and prepare them for sql IN clause
553
-                $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
553
+                $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'";
554 554
             }
555 555
             if (!file_exists($filecontent))
556
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
556
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>";
557 557
             else {
558 558
 
559 559
                 // disable legacy versions based on legacy_names provided
560
-                if(!empty($leg_names)) {
561
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
560
+                if (!empty($leg_names)) {
561
+                    $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
562 562
                     $rs = mysqli_query($sqlParser->conn, $update_query);
563 563
                 }
564 564
 
@@ -568,50 +568,50 @@  discard block
 block discarded – undo
568 568
                 $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
569 569
                 $plugin = removeDocblock($plugin, 'plugin');
570 570
                 $plugin = mysqli_real_escape_string($conn, $plugin);
571
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'");
571
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'");
572 572
                 if (mysqli_num_rows($rs)) {
573 573
                     $insert = true;
574
-                    while($row = mysqli_fetch_assoc($rs)) {
575
-                        $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
576
-                        if($row['description'] == $desc){
577
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
578
-                                echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
574
+                    while ($row = mysqli_fetch_assoc($rs)) {
575
+                        $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
576
+                        if ($row['description'] == $desc) {
577
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
578
+                                echo "<p>".mysqli_error($sqlParser->conn)."</p>";
579 579
                                 return;
580 580
                             }
581 581
                             $insert = false;
582 582
                         } else {
583
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
583
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
584 584
                                 echo "<p>".mysqli_error($sqlParser->conn)."</p>";
585 585
                                 return;
586 586
                             }
587 587
                         }
588 588
                     }
589
-                    if($insert === true) {
590
-                        $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
591
-                        if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
589
+                    if ($insert === true) {
590
+                        $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
591
+                        if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
592 592
                             echo "<p>".mysqli_error($sqlParser->conn)."</p>";
593 593
                             return;
594 594
                         }
595 595
                     }
596
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
596
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
597 597
                 } else {
598 598
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
599
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
600
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
599
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
600
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
601 601
                         return;
602 602
                     }
603
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
603
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
604 604
                 }
605 605
                 // add system events
606 606
                 if (count($events) > 0) {
607
-                    $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
607
+                    $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
608 608
                     if ($ds) {
609 609
                         $row = mysqli_fetch_assoc($ds);
610 610
                         $id = $row["id"];
611 611
                         // remove existing events
612
-                        mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\'');
612
+                        mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\'');
613 613
                         // add new events
614
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('" . implode("','", $events) . "')");
614
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`".$table_prefix."system_eventnames` se WHERE name IN ('".implode("','", $events)."')");
615 615
                     }
616 616
                 }
617 617
             }
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 
622 622
 // Install Snippets
623 623
 if (isset ($_POST['snippet']) || $installData) {
624
-    echo "<h3>" . $_lang['snippets'] . ":</h3> ";
624
+    echo "<h3>".$_lang['snippets'].":</h3> ";
625 625
     $selSnips = $_POST['snippet'];
626 626
     foreach ($moduleSnippets as $k=>$moduleSnippet) {
627 627
         $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1;
628
-        if($installSample || in_array($k, $selSnips)) {
628
+        if ($installSample || in_array($k, $selSnips)) {
629 629
             $name = mysqli_real_escape_string($conn, $moduleSnippet[0]);
630 630
             $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]);
631 631
             $filecontent = $moduleSnippet[2];
632 632
             $properties = $moduleSnippet[3];
633 633
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
634 634
             if (!file_exists($filecontent))
635
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
635
+                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>";
636 636
             else {
637 637
 
638 638
                 // Create the category if it does not already exist
@@ -641,22 +641,22 @@  discard block
 block discarded – undo
641 641
                 $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)));
642 642
                 $snippet = removeDocblock($snippet, 'snippet');
643 643
                 $snippet = mysqli_real_escape_string($conn, $snippet);
644
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'");
644
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'");
645 645
                 if (mysqli_num_rows($rs)) {
646 646
                     $row = mysqli_fetch_assoc($rs);
647
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
648
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
649
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
647
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
648
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
649
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
650 650
                         return;
651 651
                     }
652
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>";
652
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['upgraded']."</span></p>";
653 653
                 } else {
654 654
                     $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
655
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
656
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
655
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
656
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
657 657
                         return;
658 658
                     }
659
-                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
659
+                    echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">".$_lang['installed']."</span></p>";
660 660
                 }
661 661
             }
662 662
         }
@@ -665,24 +665,24 @@  discard block
 block discarded – undo
665 665
 
666 666
 // Install demo-site
667 667
 if ($installData && $moduleSQLDataFile) {
668
-    echo "<p>" . $_lang['installing_demo_site'];
668
+    echo "<p>".$_lang['installing_demo_site'];
669 669
     $sqlParser->process($moduleSQLDataFile);
670 670
     // display database results
671 671
     if ($sqlParser->installFailed == true) {
672 672
         $errors += 1;
673
-        echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>";
674
-        echo "<p>" . $_lang['setup_couldnt_install'] . "</p>";
675
-        echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />";
673
+        echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>";
674
+        echo "<p>".$_lang['setup_couldnt_install']."</p>";
675
+        echo "<p>".$_lang['installation_error_occured']."<br /><br />";
676 676
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
677
-            echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
677
+            echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />";
678 678
         }
679 679
         echo "</p>";
680
-        echo "<p>" . $_lang['some_tables_not_updated'] . "</p>";
680
+        echo "<p>".$_lang['some_tables_not_updated']."</p>";
681 681
         return;
682 682
     } else {
683 683
         $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix);
684 684
         $rs = mysqli_query($sqlParser->conn, $sql);
685
-        if(mysqli_num_rows($rs)) {
685
+        if (mysqli_num_rows($rs)) {
686 686
             $row = mysqli_fetch_assoc($rs);
687 687
             $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']);
688 688
             mysqli_query($sqlParser->conn, $sql);
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 
694 694
 // Install Dependencies
695 695
 foreach ($moduleDependencies as $dependency) {
696
-	$ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"');
696
+	$ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"');
697 697
 	if (!$ds) {
698
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
698
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
699 699
 		return;
700 700
 	} else {
701 701
 		$row = mysqli_fetch_assoc($ds);
@@ -703,37 +703,37 @@  discard block
 block discarded – undo
703 703
 		$moduleGuid = $row["guid"];
704 704
 	}
705 705
 	// get extra id
706
-	$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"');
706
+	$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"');
707 707
 	if (!$ds) {
708
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
708
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
709 709
 		return;
710 710
 	} else {
711 711
 		$row = mysqli_fetch_assoc($ds);
712 712
 		$extraId = $row["id"];
713 713
 	}
714 714
 	// setup extra as module dependency
715
-	$ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1');
715
+	$ds = mysqli_query($sqlParser->conn, 'SELECT module FROM '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type'].' LIMIT 1');
716 716
 	if (!$ds) {
717
-		echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
717
+		echo "<p>".mysqli_error($sqlParser->conn)."</p>";
718 718
 		return;
719 719
 	} else {
720 720
 		if (mysqli_num_rows($ds) === 0) {
721
-			mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')');
722
-			echo '<p>&nbsp;&nbsp;' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>';
721
+			mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')');
722
+			echo '<p>&nbsp;&nbsp;'.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>';
723 723
 		} else {
724
-			mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']);
725
-			echo '<p>&nbsp;&nbsp;' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>';
724
+			mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` SET module = '.$moduleId.', resource = '.$extraId.', type = '.$dependency['type'].' WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type']);
725
+			echo '<p>&nbsp;&nbsp;'.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>';
726 726
 		}
727 727
 		if ($dependency['type'] == 30 || $dependency['type'] == 40) {
728 728
 			// set extra guid for plugins and snippets
729
-			$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1');
729
+			$ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1');
730 730
 			if (!$ds) {
731
-				echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
731
+				echo "<p>".mysqli_error($sqlParser->conn)."</p>";
732 732
 				return;
733 733
 			} else {
734 734
 				if (mysqli_num_rows($ds) != 0) {
735
-					mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId);
736
-					echo '<p>&nbsp;&nbsp;' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>';
735
+					mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId);
736
+					echo '<p>&nbsp;&nbsp;'.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>';
737 737
 				}
738 738
 			}
739 739
 		}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 
743 743
 // call back function
744 744
 if ($callBackFnc != "")
745
-    $callBackFnc ($sqlParser);
745
+    $callBackFnc($sqlParser);
746 746
 
747 747
 // Setup the MODX API -- needed for the cache processor
748 748
 define('MODX_API_MODE', true);
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
 }
778 778
 
779 779
 // setup completed!
780
-echo "<p><b>" . $_lang['installation_successful'] . "</b></p>";
781
-echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
780
+echo "<p><b>".$_lang['installation_successful']."</b></p>";
781
+echo "<p>".$_lang['to_log_into_content_manager']."</p>";
782 782
 if ($installMode == 0) {
783
-    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>";
783
+    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>";
784 784
 } else {
785
-    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>";
785
+    echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>";
786 786
 }
787 787
 
788 788
 /**
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
  * @param string $old
793 793
  * @return string
794 794
  */
795
-function propUpdate($new,$old){
795
+function propUpdate($new, $old){
796 796
     $newArr = parseProperties($new);
797 797
     $oldArr = parseProperties($old);
798
-    foreach ($oldArr as $k => $v){
799
-        if (isset($v['0']['options'])){
798
+    foreach ($oldArr as $k => $v) {
799
+        if (isset($v['0']['options'])) {
800 800
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
801 801
         }
802 802
     }
@@ -811,30 +811,30 @@  discard block
 block discarded – undo
811 811
  * @param bool|mixed $json
812 812
  * @return string
813 813
  */
814
-function parseProperties($propertyString, $json=false) {
815
-    $propertyString = str_replace('{}', '', $propertyString );
816
-    $propertyString = str_replace('} {', ',', $propertyString );
814
+function parseProperties($propertyString, $json = false){
815
+    $propertyString = str_replace('{}', '', $propertyString);
816
+    $propertyString = str_replace('} {', ',', $propertyString);
817 817
 
818
-    if(empty($propertyString)) return array();
819
-    if($propertyString=='{}' || $propertyString=='[]') return array();
818
+    if (empty($propertyString)) return array();
819
+    if ($propertyString == '{}' || $propertyString == '[]') return array();
820 820
 
821 821
     $jsonFormat = isJson($propertyString, true);
822 822
     $property = array();
823 823
     // old format
824
-    if ( $jsonFormat === false) {
825
-        $props= explode('&', $propertyString);
824
+    if ($jsonFormat === false) {
825
+        $props = explode('&', $propertyString);
826 826
         foreach ($props as $prop) {
827 827
             $prop = trim($prop);
828
-            if($prop === '') {
828
+            if ($prop === '') {
829 829
                 continue;
830 830
             }
831 831
 
832 832
             $arr = explode(';', $prop);
833
-            if( ! is_array($arr)) {
833
+            if (!is_array($arr)) {
834 834
                 $arr = array();
835 835
             }
836 836
             $key = explode('=', isset($arr[0]) ? $arr[0] : '');
837
-            if( ! is_array($key) || empty($key[0])) {
837
+            if (!is_array($key) || empty($key[0])) {
838 838
                 continue;
839 839
             }
840 840
 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 
859 859
         }
860 860
     // new json-format
861
-    } else if(!empty($jsonFormat)){
861
+    } else if (!empty($jsonFormat)) {
862 862
         $property = $jsonFormat;
863 863
     }
864 864
     if ($json) {
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
  * @param bool $returnData
874 874
  * @return bool|mixed
875 875
  */
876
-function isJson($string, $returnData=false) {
876
+function isJson($string, $returnData = false){
877 877
     $data = json_decode($string, true);
878 878
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
879 879
 }
@@ -883,20 +883,20 @@  discard block
 block discarded – undo
883 883
  * @param SqlParser $sqlParser
884 884
  * @return int
885 885
  */
886
-function getCreateDbCategory($category, $sqlParser) {
886
+function getCreateDbCategory($category, $sqlParser){
887 887
     $dbase = $sqlParser->dbname;
888
-    $dbase = '`' . trim($dbase,'`') . '`';
888
+    $dbase = '`'.trim($dbase, '`').'`';
889 889
     $table_prefix = $sqlParser->prefix;
890 890
     $category_id = 0;
891
-    if(!empty($category)) {
891
+    if (!empty($category)) {
892 892
         $category = mysqli_real_escape_string($sqlParser->conn, $category);
893 893
         $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'");
894
-        if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
894
+        if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
895 895
             $category_id = $row['id'];
896 896
         } else {
897 897
             $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');";
898 898
             $rs = mysqli_query($sqlParser->conn, $q);
899
-            if($rs) {
899
+            if ($rs) {
900 900
                 $category_id = mysqli_insert_id($sqlParser->conn);
901 901
             }
902 902
         }
@@ -911,12 +911,12 @@  discard block
 block discarded – undo
911 911
  * @param string $type
912 912
  * @return string
913 913
  */
914
-function removeDocblock($code, $type) {
914
+function removeDocblock($code, $type){
915 915
 
916 916
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
917 917
 
918 918
     // Procedure taken from plugin.filesource.php
919
-    switch($type) {
919
+    switch ($type) {
920 920
         case 'snippet':
921 921
             $elm_name = 'snippets';
922 922
             $include = 'return require';
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
         default:
933 933
             return $cleaned;
934 934
     };
935
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
935
+    if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
936 936
         return $cleaned;
937 937
 
938 938
     // fileBinding not found - return code incl docblock
Please login to merge, or discard this patch.
manager/actions/resources/functions.inc.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 
6 6
 $tpl = array(
7
-	'viewForm' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_viewForm.tpl'),
8
-	'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
9
-	'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
10
-	'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
11
-	'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl')
7
+	'viewForm' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_viewForm.tpl'),
8
+	'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'),
9
+	'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'),
10
+	'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'),
11
+	'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl')
12 12
 );
13 13
 
14 14
 /**
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @param array $ph
17 17
  * @return string
18 18
  */
19
-function parsePh($tpl, $ph) {
19
+function parsePh($tpl, $ph){
20 20
 	global $modx, $_lang;
21 21
 	$tpl = $modx->parseText($tpl, $_lang, '[%', '%]');
22 22
 	return $modx->parseText($tpl, $ph);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @param string|int $cssId
27 27
  * @return string
28 28
  */
29
-function renderViewSwitchButtons($cssId) {
29
+function renderViewSwitchButtons($cssId){
30 30
 	global $modx, $_lang, $tpl;
31 31
 
32 32
 	return parsePh($tpl['viewForm'], array(
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
  * @param mgrResources $resources
40 40
  * @return string
41 41
  */
42
-function createResourceList($resourceTable, $resources) {
42
+function createResourceList($resourceTable, $resources){
43 43
 	global $modx, $_lang, $_style, $modx_textdir, $tpl;
44 44
 
45 45
 	$items = isset($resources->items[$resourceTable]) ? $resources->items[$resourceTable] : false;
46 46
 
47
-	if( ! is_array($items) || empty($items)) {
47
+	if (!is_array($items) || empty($items)) {
48 48
 		return $_lang['no_results'];
49 49
 	}
50 50
 
51 51
 	// Prepare elements- and categories-list
52 52
 	$elements = array();
53 53
 	$categories = array();
54
-	foreach($items as $row) {
54
+	foreach ($items as $row) {
55 55
 		$catid = $row['catid'] ? $row['catid'] : 0;
56 56
 		$categories[$catid] = array('name' => stripslashes($row['category']));
57 57
 		$elements[$catid][] = prepareElementRowPh($row, $resourceTable, $resources);
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 
60 60
 	// Now render categories / panel-collapse
61 61
 	$panelGroup = '';
62
-	foreach($elements as $catid => $elList) {
62
+	foreach ($elements as $catid => $elList) {
63 63
 		// Add panel-heading / category-collapse to output
64 64
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
65 65
 			'tab' => $resourceTable,
66 66
 			'category' => $categories[$catid]['name'],
67
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
67
+			'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
68 68
 			'catid' => $catid,
69 69
 		));
70 70
 
71 71
 		// Prepare content for panel-collapse
72 72
 		$panelCollapse = '';
73
-		foreach($elList as $el) {
73
+		foreach ($elList as $el) {
74 74
 			$panelCollapse .= parsePh($tpl['elementsRow'], $el);
75 75
 		}
76 76
 
@@ -92,30 +92,30 @@  discard block
 block discarded – undo
92 92
  * @param mgrResources $resources
93 93
  * @return string
94 94
  */
95
-function createCombinedView($resources) {
95
+function createCombinedView($resources){
96 96
 	global $modx, $_lang, $_style, $modx_textdir;
97 97
 
98 98
 	$itemsPerCategory = isset($resources->itemsPerCategory) ? $resources->itemsPerCategory : false;
99 99
 	$types = isset($resources->types) ? $resources->types : false;
100 100
 	$categories = isset($resources->categories) ? $resources->categories : false;
101 101
 
102
-	if(!$itemsPerCategory) {
102
+	if (!$itemsPerCategory) {
103 103
 		return $_lang['no_results'];
104 104
 	}
105 105
 
106 106
 	$tpl = array(
107
-		'panelGroup' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelGroup.tpl'),
108
-		'panelHeading' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelHeading.tpl'),
109
-		'panelCollapse' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_panelCollapse.tpl'),
110
-		'elementsRow' => file_get_contents(MODX_MANAGER_PATH . 'actions/resources/tpl_elementsRow.tpl'),
107
+		'panelGroup' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelGroup.tpl'),
108
+		'panelHeading' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelHeading.tpl'),
109
+		'panelCollapse' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_panelCollapse.tpl'),
110
+		'elementsRow' => file_get_contents(MODX_MANAGER_PATH.'actions/resources/tpl_elementsRow.tpl'),
111 111
 	);
112 112
 
113 113
 	// Easily loop through $itemsPerCategory-Array
114 114
 	$panelGroup = '';
115
-	foreach($categories as $catid => $category) {
115
+	foreach ($categories as $catid => $category) {
116 116
 		// Prepare collapse content / elements-list
117 117
 		$panelCollapse = '';
118
-		foreach($itemsPerCategory[$catid] as $el) {
118
+		foreach ($itemsPerCategory[$catid] as $el) {
119 119
 			$resourceTable = $el['type'];
120 120
 			$ph = prepareElementRowPh($el, $resourceTable, $resources);
121 121
 			$panelCollapse .= parsePh($tpl['elementsRow'], $ph);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		$panelGroup .= parsePh($tpl['panelHeading'], array(
126 126
 			'tab' => 'categories_list',
127 127
 			'category' => $categories[$catid],
128
-			'categoryid' => $catid != '' ? ' <small>(' . $catid . ')</small>' : '',
128
+			'categoryid' => $catid != '' ? ' <small>('.$catid.')</small>' : '',
129 129
 			'catid' => $catid,
130 130
 		));
131 131
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
  * @param mgrResources $resources
150 150
  * @return array
151 151
  */
152
-function prepareElementRowPh($row, $resourceTable, $resources) {
152
+function prepareElementRowPh($row, $resourceTable, $resources){
153 153
 	global $modx, $modx_textdir, $_style, $_lang;
154 154
 
155 155
 	$types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false;
156 156
 
157 157
 	$_lang["confirm_delete"] = $_lang["delete"];
158 158
 
159
-	switch($resourceTable){
159
+	switch ($resourceTable) {
160 160
         case 'site_templates':
161 161
             $class = $row['selectable'] ? '' : 'disabledPlugin';
162 162
             $lockElementType = 1;
@@ -193,65 +193,65 @@  discard block
 block discarded – undo
193 193
 	// Prepare displaying user-locks
194 194
 	$lockedByUser = '';
195 195
 	$rowLock = $modx->elementIsLocked($lockElementType, $row['id'], true);
196
-	if($rowLock && $modx->hasPermission('display_locks')) {
197
-		if($rowLock['sid'] == $modx->sid) {
196
+	if ($rowLock && $modx->hasPermission('display_locks')) {
197
+		if ($rowLock['sid'] == $modx->sid) {
198 198
 			$title = $modx->parseText($_lang["lock_element_editing"], array(
199
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
199
+				'element_type' => $_lang["lock_element_type_".$lockElementType],
200 200
 				'lasthit_df' => $rowLock['lasthit_df']
201 201
 			));
202
-			$lockedByUser = '<span title="' . $title . '" class="editResource" style="cursor:context-menu;">' . $_style['tree_preview_resource'] . '</span>&nbsp;';
202
+			$lockedByUser = '<span title="'.$title.'" class="editResource" style="cursor:context-menu;">'.$_style['tree_preview_resource'].'</span>&nbsp;';
203 203
 		} else {
204 204
 			$title = $modx->parseText($_lang["lock_element_locked_by"], array(
205
-				'element_type' => $_lang["lock_element_type_" . $lockElementType],
205
+				'element_type' => $_lang["lock_element_type_".$lockElementType],
206 206
 				'username' => $rowLock['username'],
207 207
 				'lasthit_df' => $rowLock['lasthit_df']
208 208
 			));
209
-			if($modx->hasPermission('remove_locks')) {
210
-				$lockedByUser = '<a href="javascript:;" onclick="unlockElement(' . $lockElementType . ', ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource"><i class="' . $_style['icons_secured'] . '"></i></a>';
209
+			if ($modx->hasPermission('remove_locks')) {
210
+				$lockedByUser = '<a href="javascript:;" onclick="unlockElement('.$lockElementType.', '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource"><i class="'.$_style['icons_secured'].'"></i></a>';
211 211
 			} else {
212
-				$lockedByUser = '<span title="' . $title . '" class="lockedResource" style="cursor:context-menu;"><i class="' . $_style['icons_secured'] . '"></i></span>';
212
+				$lockedByUser = '<span title="'.$title.'" class="lockedResource" style="cursor:context-menu;"><i class="'.$_style['icons_secured'].'"></i></span>';
213 213
 			}
214 214
 		}
215 215
 	}
216
-	if($lockedByUser) {
217
-		$lockedByUser = '<div class="lockCell">' . $lockedByUser . '</div>';
216
+	if ($lockedByUser) {
217
+		$lockedByUser = '<div class="lockCell">'.$lockedByUser.'</div>';
218 218
 	}
219 219
 
220 220
 	// Caption
221
-	if($resourceTable == 'site_tmplvars') {
222
-		$caption = !empty($row['description']) ? ' ' . $row['caption'] . ' &nbsp; <small>(' . $row['description'] . ')</small>' : ' ' . $row['caption'];
221
+	if ($resourceTable == 'site_tmplvars') {
222
+		$caption = !empty($row['description']) ? ' '.$row['caption'].' &nbsp; <small>('.$row['description'].')</small>' : ' '.$row['caption'];
223 223
 	} else {
224
-		$caption = !empty($row['description']) ? ' ' . $row['description'] : '';
224
+		$caption = !empty($row['description']) ? ' '.$row['description'] : '';
225 225
 	}
226 226
 
227 227
 	// Special marks
228 228
 	$tplInfo = array();
229
-	if($row['locked']) {
229
+	if ($row['locked']) {
230 230
 		$tplInfo[] = $_lang['locked'];
231 231
 	}
232
-	if($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
232
+	if ($row['id'] == $modx->config['default_template'] && $resourceTable == 'site_templates') {
233 233
 		$tplInfo[] = $_lang['defaulttemplate_title'];
234 234
 	}
235
-	$marks = !empty($tplInfo) ? ' <em>(' . implode(', ', $tplInfo) . ')</em>' : '';
235
+	$marks = !empty($tplInfo) ? ' <em>('.implode(', ', $tplInfo).')</em>' : '';
236 236
 
237 237
 	/* row buttons */
238 238
 	$buttons = '';
239
-	if($modx->hasPermission($types['actions']['edit'][1])) {
240
-		$buttons .= '<li><a title="' . $_lang["edit_resource"] . '" href="index.php?a=' . $types['actions']['edit'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-edit fa-fw"></i></a></li>';
239
+	if ($modx->hasPermission($types['actions']['edit'][1])) {
240
+		$buttons .= '<li><a title="'.$_lang["edit_resource"].'" href="index.php?a='.$types['actions']['edit'][0].'&amp;id='.$row['id'].'"><i class="fa fa-edit fa-fw"></i></a></li>';
241 241
 	}
242
-	if($modx->hasPermission($types['actions']['duplicate'][1])) {
243
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_duplicate_record"] . '\')" title="' . $_lang["resource_duplicate"] . '" href="index.php?a=' . $types['actions']['duplicate'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-clone fa-fw"></i></a></li>';
242
+	if ($modx->hasPermission($types['actions']['duplicate'][1])) {
243
+		$buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_duplicate_record"].'\')" title="'.$_lang["resource_duplicate"].'" href="index.php?a='.$types['actions']['duplicate'][0].'&amp;id='.$row['id'].'"><i class="fa fa-clone fa-fw"></i></a></li>';
244 244
 	}
245
-	if($modx->hasPermission($types['actions']['remove'][1])) {
246
-		$buttons .= '<li><a onclick="return confirm(\'' . $_lang["confirm_delete"] . '\')" title="' . $_lang["delete"] . '" href="index.php?a=' . $types['actions']['remove'][0] . '&amp;id=' . $row['id'] . '"><i class="fa fa-trash fa-fw"></i></a></li>';
245
+	if ($modx->hasPermission($types['actions']['remove'][1])) {
246
+		$buttons .= '<li><a onclick="return confirm(\''.$_lang["confirm_delete"].'\')" title="'.$_lang["delete"].'" href="index.php?a='.$types['actions']['remove'][0].'&amp;id='.$row['id'].'"><i class="fa fa-trash fa-fw"></i></a></li>';
247 247
 	}
248
-	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">' . $buttons . '</ul></div>' : '';
248
+	$buttons = $buttons ? '<div class="btnCell"><ul class="elements_buttonbar">'.$buttons.'</ul></div>' : '';
249 249
 
250 250
 	$catid = $row['catid'] ? $row['catid'] : 0;
251 251
 
252 252
 	// Placeholders for elements-row
253 253
 	return array(
254
-		'class' => $class ? ' class="' . $class . '"' : '',
254
+		'class' => $class ? ' class="'.$class.'"' : '',
255 255
 		'lockedByUser' => $lockedByUser,
256 256
 		'name' => $row['name'],
257 257
 		'caption' => $caption,
Please login to merge, or discard this patch.