Completed
Push — develop ( d568f8...c061fc )
by Agel_Nash
06:25
created
manager/actions/import_site.static.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -346,7 +346,7 @@
 block discarded – undo
346 346
 
347 347
 /**
348 348
  * @param string $filepath
349
- * @return bool|string
349
+ * @return null|string
350 350
  */
351 351
 function getFileContent($filepath)
352 352
 {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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('import_static')) {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		<div class="container container-body">
45 45
 			<?php
46 46
             if (!isset($_POST['import'])) {
47
-                echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>"; ?>
47
+                echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>"; ?>
48 48
 				<form action="index.php" method="post" name="importFrm">
49 49
 					<input type="hidden" name="import" value="import" />
50 50
 					<input type="hidden" name="a" value="95" />
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
         $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128 128
     }
129 129
 
130
-    $parent = (int)$_POST['parent'];
130
+    $parent = (int) $_POST['parent'];
131 131
 
132
-    if (is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-        $filedir = MODX_BASE_PATH . 'temp/import/';
134
-    } elseif (is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-        $filedir = MODX_BASE_PATH . 'assets/import/';
132
+    if (is_dir(MODX_BASE_PATH.'temp/import')) {
133
+        $filedir = MODX_BASE_PATH.'temp/import/';
134
+    } elseif (is_dir(MODX_BASE_PATH.'assets/import')) {
135
+        $filedir = MODX_BASE_PATH.'assets/import/';
136 136
     } else {
137 137
         $filedir = '';
138 138
     }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     $files = pop_index($files);
144 144
 
145 145
     // no. of files to import
146
-    $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
146
+    $output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound);
147 147
 
148 148
     // import files
149 149
     if (0 < count($files)) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     $mtime = $mtime[1] + $mtime[0];
157 157
     $importend = $mtime;
158 158
     $totaltime = ($importend - $importstart);
159
-    $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
159
+    $output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3));
160 160
 
161 161
     if ($_POST['convert_link'] == 'on') {
162 162
         convertLink();
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         if (is_array($value)) {
196 196
             // create folder
197 197
             $alias = $id;
198
-            printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
+            printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias);
199 199
             $field = array();
200 200
             $field['type'] = 'document';
201 201
             $field['contentType'] = 'text/html';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                         'index.html',
215 215
                         'index.htm'
216 216
                     ) as $filename) {
217
-                $filepath = $filedir . $alias . '/' . $filename;
217
+                $filepath = $filedir.$alias.'/'.$filename;
218 218
                 if ($find === false && file_exists($filepath)) {
219 219
                     $file = getFileContent($filepath);
220 220
                     list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
                     $newid = $modx->db->insert($field, $tbl_site_content);
230 230
                     if ($newid) {
231 231
                         $find = true;
232
-                        echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
233
-                        importFiles($newid, $filedir . $alias . '/', $value, 'sub');
232
+                        echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
233
+                        importFiles($newid, $filedir.$alias.'/', $value, 'sub');
234 234
                     } else {
235
-                        echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
+                        echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
236 236
                         exit;
237 237
                     }
238 238
                 }
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
                 $newid = $modx->db->insert($field, $tbl_site_content);
248 248
                 if ($newid) {
249 249
                     $find = true;
250
-                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
251
-                    importFiles($newid, $filedir . $alias . '/', $value, 'sub');
250
+                    echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
251
+                    importFiles($newid, $filedir.$alias.'/', $value, 'sub');
252 252
                 } else {
253
-                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
+                    echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
254 254
                     exit;
255 255
                 }
256 256
             }
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
             $fparts = explode('.', $value);
264 264
             $alias = $fparts[0];
265 265
             $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
266
-            printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
+            printf("<span>".$_lang['import_site_importing_document']."</span>", $filename);
267 267
 
268 268
             if (!in_array($ext, $allowedfiles)) {
269
-                echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
+                echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n";
270 270
             } else {
271
-                $filepath = $filedir . $filename;
271
+                $filepath = $filedir.$filename;
272 272
                 $file = getFileContent($filepath);
273 273
                 list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
274 274
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
                 $field['menuindex'] = ($alias == 'index') ? 0 : 2;
295 295
                 $newid = $modx->db->insert($field, $tbl_site_content);
296 296
                 if ($newid) {
297
-                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
+                    echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
298 298
                 } else {
299
-                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
+                    echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
300 300
                     exit;
301 301
                 }
302 302
 
@@ -324,14 +324,14 @@  discard block
 block discarded – undo
324 324
     global $_lang;
325 325
     global $filesfound;
326 326
     $dummy = $count;
327
-    if (! empty($directory) && $files = scandir($directory)) {
327
+    if (!empty($directory) && $files = scandir($directory)) {
328 328
         foreach ($files as $file) {
329 329
             if ($file == '.' || $file == '..') {
330 330
                 continue;
331
-            } elseif ($h = @opendir($directory . $file . "/")) {
331
+            } elseif ($h = @opendir($directory.$file."/")) {
332 332
                 closedir($h);
333 333
                 $count = -1;
334
-                $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
334
+                $listing[$file] = getFiles($directory.$file."/", array(), $count + 1);
335 335
             } elseif (strpos($file, '.htm') !== false) {
336 336
                 $listing[$dummy] = $file;
337 337
                 $dummy = $dummy + 1;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             }
340 340
         }
341 341
     } else {
342
-        echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
342
+        echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>";
343 343
     }
344 344
     return ($listing);
345 345
 }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     global $_lang;
354 354
     // get the file
355 355
     if (!$buffer = file_get_contents($filepath)) {
356
-        echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
356
+        echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>";
357 357
     } else {
358 358
         return $buffer;
359 359
     }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     } else {
416 416
         $content = $src;
417 417
         $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
418
-        $r = '$1' . $modx->config['modx_charset'] . '$2';
418
+        $r = '$1'.$modx->config['modx_charset'].'$2';
419 419
         $content = preg_replace($s, $r, $content);
420 420
         $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
421 421
     }
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
                 list($href, $v) = explode('"', $v, 2);
452 452
                 $_ = $href;
453 453
                 if (strpos($_, $modx->config['site_url']) !== false) {
454
-                    $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
454
+                    $_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_);
455 455
                 }
456 456
                 if ($_[0] === '/') {
457 457
                     $_ = substr($_, 1);
@@ -478,15 +478,15 @@  discard block
 block discarded – undo
478 478
                 if (strpos($_, '/') !== false) {
479 479
                     $_ = substr($_, strrpos($_, '/'));
480 480
                 }
481
-                $_ = $dir . str_replace('.html', '', $_);
481
+                $_ = $dir.str_replace('.html', '', $_);
482 482
                 if (!isset($target[$_])) {
483 483
                     $target[$_] = $modx->getIdFromAlias($_);
484 484
                 }
485 485
                 $target[$_] = trim($target[$_]);
486 486
                 if (!empty($target[$_])) {
487
-                    $href = '[~' . $target[$_] . '~]';
487
+                    $href = '[~'.$target[$_].'~]';
488 488
                 }
489
-                $array[$c] = '<a href="' . $href . '"' . $v;
489
+                $array[$c] = '<a href="'.$href.'"'.$v;
490 490
             }
491 491
             $c++;
492 492
         }
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -72,6 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
+    /**
76
+     * @param null|string $id
77
+     * @param string $ds
78
+     */
75 79
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1)
76 80
     {
77 81
         global $__DataGridCnt;
@@ -212,6 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
     // format column values
214 218
 
219
+    /**
220
+     * @param integer $n
221
+     */
215 222
     public function RenderRowFnc($n, $row)
216 223
     {
217 224
         if ($this->_alt == 0) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public $ds; // datasource
16 16
     public $id;
17
-    public $pageSize;            // pager settings
17
+    public $pageSize; // pager settings
18 18
     public $pageNumber;
19 19
     public $pager;
20
-    public $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
20
+    public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21 21
 
22 22
     public $cssStyle;
23 23
     public $cssClass;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public $colAligns;
36 36
     public $colWraps;
37 37
     public $colColors;
38
-    public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
38
+    public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39 39
     // data type: integer,float,currency,date
40 40
 
41 41
     public $header;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public $cellPadding;
44 44
     public $cellSpacing;
45 45
 
46
-    public $rowAlign;            // vertical alignment: top, middle, bottom
46
+    public $rowAlign; // vertical alignment: top, middle, bottom
47 47
     public $rowIdField;
48 48
 
49 49
     public $pagerStyle;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         // set id
80 80
         $__DataGridCnt++;
81
-        $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
81
+        $this->id = $this->id ? empty($id) : "dg".$__DataGridCnt;
82 82
 
83 83
         // set datasource
84 84
         $this->ds = $ds;
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
     public function render()
98 98
     {
99 99
         $modx = evolutionCMS();
100
-        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
101
-        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
102
-        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
103
-        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
100
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : '';
101
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : "";
102
+        $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : '';
103
+        $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : '';
104 104
 
105
-        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
106
-        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
105
+        $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : '';
106
+        $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'";
107 107
 
108
-        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
109
-        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
110
-        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
111
-        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
108
+        $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : '';
109
+        $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : '';
110
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : '';
111
+        $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : '';
112 112
 
113 113
         $this->_alt = 0;
114 114
         $this->_total = 0;
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         if ($this->_isDataset && !$this->columns) {
132 132
             $cols = $modx->db->numFields($this->ds);
133 133
             for ($i = 0; $i < $cols; $i++) {
134
-                $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
134
+                $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i);
135 135
             }
136 136
         }
137 137
 
138 138
         // start grid
139
-        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
139
+        $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>";
140 140
         $tblEnd = "</table>";
141 141
 
142 142
         // build column header
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         for ($c = 0; $c < $this->_colcount; $c++) {
156 156
             $name = $this->_colnames[$c];
157 157
             $width = $this->_colwidths[$c];
158
-            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
158
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>";
159 159
         }
160 160
         $tblColHdr .= "</tr></thead>\n";
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
164 164
         $this->_fieldnames = explode(",", $this->fields);
165 165
         if ($rowcount == 0) {
166
-            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
166
+            $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n";
167 167
         } else {
168 168
             // render grid items
169 169
             if ($this->pageSize <= 0) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 }
174 174
             } else {
175 175
                 if (!$this->pager) {
176
-                    include_once dirname(__FILE__) . "/datasetpager.class.php";
176
+                    include_once dirname(__FILE__)."/datasetpager.class.php";
177 177
                     $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
178 178
                     $this->pager->setRenderRowFnc($this); // pass this object
179 179
                     $this->pager->cssStyle = $pagerStyle;
@@ -194,17 +194,17 @@  discard block
 block discarded – undo
194 194
         $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
195 195
         $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
196 196
         if ($this->header) {
197
-            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
197
+            $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>";
198 198
         }
199 199
         if ($tblPager && $ptop) {
200
-            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+            $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
201 201
         }
202
-        $o .= $tblColHdr . $tblRows;
202
+        $o .= $tblColHdr.$tblRows;
203 203
         if ($tblPager && $pbot) {
204
-            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
204
+            $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
205 205
         }
206 206
         if ($this->footer) {
207
-            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
207
+            $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>";
208 208
         }
209 209
         $o .= $tblEnd;
210 210
         return $o;
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
             $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
235 235
             $value = $row[($this->_isDataset && $fld ? $fld : $c)];
236 236
             if ($color && $Style) {
237
-                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
237
+                $colStyle = substr($colStyle, 0, -1).";background-color:$color;'";
238 238
             }
239 239
             $value = $this->formatColumnValue($row, $value, $type, $align);
240
-            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
240
+            $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>";
241 241
         }
242 242
         $o .= "</tr>\n";
243 243
         return $o;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                 if (!$type_format) {
274 274
                     $type_format = 2;
275 275
                 }
276
-                $value = "$" . number_format($value, $type_format);
276
+                $value = "$".number_format($value, $type_format);
277 277
                 break;
278 278
 
279 279
             case "date":
Please login to merge, or discard this patch.
manager/includes/controls/datasetpager.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
+    /**
35
+     * @param boolean|string $id
36
+     */
34 37
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
35 38
     {
36 39
         global $_PAGE; // use view state object
@@ -82,6 +85,9 @@  discard block
 block discarded – undo
82 85
         $this->pageSize = $ps;
83 86
     }
84 87
 
88
+    /**
89
+     * @param DataGrid $fncName
90
+     */
85 91
     public function setRenderRowFnc($fncName, $args = "")
86 92
     {
87 93
         $this->renderRowFnc = &$fncName;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 
40 40
         // set id
41 41
         $__DataSetPagerCnt++;
42
-        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
+        $this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt;
43 43
 
44 44
         // get pagenumber
45 45
         // by setting pager to -1 cause pager to load it's last page number
46 46
         if ($pageNumber == -1) {
47 47
             $pageNumber = 1;
48
-            if (isset($_GET["dpgn" . $this->id])) {
49
-                $pageNumber = $_GET["dpgn" . $this->id];
50
-            } elseif (isset($_PAGE['vs'][$id . '_dpgn'])) {
51
-                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
48
+            if (isset($_GET["dpgn".$this->id])) {
49
+                $pageNumber = $_GET["dpgn".$this->id];
50
+            } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) {
51
+                $pageNumber = $_PAGE['vs'][$id.'_dpgn'];
52 52
             }
53 53
         }
54 54
         if (!is_numeric($pageNumber)) {
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
     public function setRenderRowFnc($fncName, $args = "")
86 86
     {
87 87
         $this->renderRowFnc = &$fncName;
88
-        $this->renderRowFncArgs = $args;    // extra agruments
88
+        $this->renderRowFncArgs = $args; // extra agruments
89 89
     }
90 90
 
91 91
     public function setRenderPagerFnc($fncName, $args = "")
92 92
     {
93 93
         $this->renderPagerFnc = $fncName;
94
-        $this->renderPagerFncArgs = $args;    // extra agruments
94
+        $this->renderPagerFncArgs = $args; // extra agruments
95 95
     }
96 96
 
97 97
     public function render()
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
         // save page number to view state if available
136 136
         if (isset($_PAGE['vs'])) {
137
-            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
137
+            $_PAGE['vs'][$this->id.'_dpgn'] = $p;
138 138
         }
139 139
 
140 140
         // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
             $args = $this->renderPagerFncArgs;
145 145
             if (!isset($fnc)) {
146 146
                 if ($modx->isFrontend()) {
147
-                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
147
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?';
148 148
                 } else {
149
-                    $url = $_SERVER['PHP_SELF'] . '?';
149
+                    $url = $_SERVER['PHP_SELF'].'?';
150 150
                 }
151 151
                 $i = 0;
152 152
                 foreach ($_GET as $n => $v) {
153
-                    if ($n != 'dpgn' . $this->id) {
153
+                    if ($n != 'dpgn'.$this->id) {
154 154
                         $i++;
155
-                        $url .= (($i > 1) ? "&" : "") . "$n=$v";
155
+                        $url .= (($i > 1) ? "&" : "")."$n=$v";
156 156
                     }
157 157
                 }
158 158
                 if ($i >= 1) {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                         $this->pager .= $fnc($p, $i);
168 168
                     }
169 169
                 } else {
170
-                    $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
170
+                    $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> ";
171 171
                 }
172 172
             }
173 173
         }
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysql.class.inc.php 1 patch
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -412,6 +412,9 @@  discard block
 block discarded – undo
412 412
         }
413 413
     }
414 414
 
415
+    /**
416
+     * @param string $table
417
+     */
415 418
     public function save($fields, $table, $where = '')
416 419
     {
417 420
         if ($where === '') {
@@ -441,6 +444,7 @@  discard block
 block discarded – undo
441 444
     /**
442 445
      * @name:  freeResult
443 446
      *
447
+     * @param mysqli_result $rs
444 448
      */
445 449
     public function freeResult($rs)
446 450
     {
@@ -551,6 +555,7 @@  discard block
 block discarded – undo
551 555
      * @name:  getColumn
552 556
      * @desc:  returns an array of the values found on colun $name
553 557
      * @param: $dsq - dataset or query string
558
+     * @param string $name
554 559
      */
555 560
     public function getColumn($name, $dsq)
556 561
     {
@@ -716,6 +721,9 @@  discard block
 block discarded – undo
716 721
         return $result;
717 722
     }
718 723
 
724
+    /**
725
+     * @param string $table_name
726
+     */
719 727
     public function optimize($table_name)
720 728
     {
721 729
         $rs = $this->query("OPTIMIZE TABLE {$table_name}");
@@ -726,6 +734,9 @@  discard block
 block discarded – undo
726 734
         return $rs;
727 735
     }
728 736
 
737
+    /**
738
+     * @param string $table_name
739
+     */
729 740
     public function truncate($table_name)
730 741
     {
731 742
         $rs = $this->query("TRUNCATE {$table_name}");
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 3 patches
Doc Comments   +27 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @param string $mode
103 103
      * @param string $modifiers
104
-     * @return bool|string
104
+     * @return false|string
105 105
      */
106 106
     public function _getDelim($mode, $modifiers)
107 107
     {
@@ -149,6 +149,14 @@  discard block
 block discarded – undo
149 149
             return $opt;
150 150
         }
151 151
     }
152
+
153
+    /**
154
+     * @param string $mode
155
+     * @param false|string $delim
156
+     * @param string $modifiers
157
+     *
158
+     * @return string
159
+     */
152 160
     public function _getRemainModifiers($mode, $delim, $modifiers)
153 161
     {
154 162
         if ($delim) {
@@ -182,6 +190,9 @@  discard block
 block discarded – undo
182 190
         return substr($string, strpos($string, $delim)+$len);
183 191
     }
184 192
 
193
+    /**
194
+     * @param string $modifiers
195
+     */
185 196
     public function splitEachModifiers($modifiers)
186 197
     {
187 198
         $modx = evolutionCMS();
@@ -253,6 +264,10 @@  discard block
 block discarded – undo
253 264
         return $result;
254 265
     }
255 266
 
267
+    /**
268
+     * @param string $key
269
+     * @param string $value
270
+     */
256 271
     public function parsePhx($key, $value, $modifiers)
257 272
     {
258 273
         $modx = evolutionCMS();
@@ -332,6 +347,10 @@  discard block
 block discarded – undo
332 347
         }
333 348
     }
334 349
 
350
+    /**
351
+     * @param string $cmd
352
+     * @param string $opt
353
+     */
335 354
     public function getValueFromPreset($key, $value, $cmd, $opt)
336 355
     {
337 356
         $modx = evolutionCMS();
@@ -1185,6 +1204,9 @@  discard block
 block discarded – undo
1185 1204
         return $value;
1186 1205
     }
1187 1206
 
1207
+    /**
1208
+     * @param string $cmd
1209
+     */
1188 1210
     public function includeMdfFile($cmd)
1189 1211
     {
1190 1212
         $modx = evolutionCMS();
@@ -1374,6 +1396,10 @@  discard block
 block discarded – undo
1374 1396
     }
1375 1397
 
1376 1398
     // Sets a placeholder variable which can only be access by Modifiers
1399
+
1400
+    /**
1401
+     * @param string $value
1402
+     */
1377 1403
     public function setModifiersVariable($key, $value)
1378 1404
     {
1379 1405
         if ($key != 'phx' && $key != 'dummy') {
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!defined('MODX_CORE_PATH')) {
4
-    define('MODX_CORE_PATH', MODX_MANAGER_PATH . 'includes/');
4
+    define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/');
5 5
 }
6 6
 
7 7
 class MODIFIERS
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     public function phxFilter($key, $value, $modifiers)
79 79
     {
80 80
         $modx = evolutionCMS();
81
-        if (substr($modifiers, 0, 3)!=='id(') {
81
+        if (substr($modifiers, 0, 3) !== 'id(') {
82 82
             $value = $this->parseDocumentSource($value);
83 83
         }
84 84
         $this->srcValue = $value;
85 85
         $modifiers = trim($modifiers);
86
-        $modifiers = ':' . trim($modifiers, ':');
87
-        $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers);
86
+        $modifiers = ':'.trim($modifiers, ':');
87
+        $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers);
88 88
         $modifiers = $this->splitEachModifiers($modifiers);
89 89
 
90 90
         $this->placeholders = array();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $this->placeholders['dummy'] = '';
93 93
         $this->condition = array();
94 94
         $this->vars = array();
95
-        $this->vars['name']    = & $key;
95
+        $this->vars['name'] = & $key;
96 96
         $value = $this->parsePhx($key, $value, $modifiers);
97 97
         $this->vars = array();
98 98
         return $value;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
         }
112 112
 
113 113
         $modifiers = substr($modifiers, 1);
114
-        $closure = $mode=='(' ? "{$c})" : $c;
115
-        if (strpos($modifiers, $closure)===false) {
114
+        $closure = $mode == '(' ? "{$c})" : $c;
115
+        if (strpos($modifiers, $closure) === false) {
116 116
             return false;
117 117
         }
118 118
 
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
     public function _getOpt($mode, $delim, $modifiers)
129 129
     {
130 130
         if ($delim) {
131
-            if ($mode=='(') {
132
-                return substr($modifiers, 1, strpos($modifiers, $delim . ')')-1);
131
+            if ($mode == '(') {
132
+                return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1);
133 133
             }
134 134
 
135
-            return substr($modifiers, 1, strpos($modifiers, $delim, 1)-1);
135
+            return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1);
136 136
         } else {
137
-            if ($mode=='(') {
137
+            if ($mode == '(') {
138 138
                 return substr($modifiers, 0, strpos($modifiers, ')'));
139 139
             }
140 140
 
141 141
             $chars = str_split($modifiers);
142
-            $opt='';
142
+            $opt = '';
143 143
             foreach ($chars as $c) {
144
-                if ($c==':' || $c==')') {
144
+                if ($c == ':' || $c == ')') {
145 145
                     break;
146 146
                 }
147
-                $opt .=$c;
147
+                $opt .= $c;
148 148
             }
149 149
             return $opt;
150 150
         }
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
     public function _getRemainModifiers($mode, $delim, $modifiers)
153 153
     {
154 154
         if ($delim) {
155
-            if ($mode=='(') {
156
-                return $this->_fetchContent($modifiers, $delim . ')');
155
+            if ($mode == '(') {
156
+                return $this->_fetchContent($modifiers, $delim.')');
157 157
             } else {
158 158
                 $modifiers = trim($modifiers);
159 159
                 $modifiers = substr($modifiers, 1);
160 160
                 return $this->_fetchContent($modifiers, $delim);
161 161
             }
162 162
         } else {
163
-            if ($mode=='(') {
163
+            if ($mode == '(') {
164 164
                 return $this->_fetchContent($modifiers, ')');
165 165
             }
166 166
             $chars = str_split($modifiers);
167 167
             foreach ($chars as $c) {
168
-                if ($c==':') {
168
+                if ($c == ':') {
169 169
                     return $modifiers;
170 170
                 } else {
171 171
                     $modifiers = substr($modifiers, 1);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $len = strlen($delim);
181 181
         $string = $this->parseDocumentSource($string);
182
-        return substr($string, strpos($string, $delim)+$len);
182
+        return substr($string, strpos($string, $delim) + $len);
183 183
     }
184 184
 
185 185
     public function splitEachModifiers($modifiers)
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
         $cmd = '';
190 190
         $bt = '';
191 191
         $result = array();
192
-        while ($bt!==$modifiers) {
192
+        while ($bt !== $modifiers) {
193 193
             $bt = $modifiers;
194 194
             $c = substr($modifiers, 0, 1);
195 195
             $modifiers = substr($modifiers, 1);
196 196
 
197
-            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
197
+            if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
198 198
                 $c = substr($modifiers, strlen($match[1]), 1);
199 199
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
200
-                if ($c==='(') {
201
-                    $modifiers = substr($modifiers, strlen($match[1])+1);
200
+                if ($c === '(') {
201
+                    $modifiers = substr($modifiers, strlen($match[1]) + 1);
202 202
                 } else {
203 203
                     $modifiers = substr($modifiers, strlen($match[1]));
204 204
                 }
@@ -207,33 +207,33 @@  discard block
 block discarded – undo
207 207
                 $opt       = $this->_getOpt($c, $delim, $modifiers);
208 208
                 $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
209 209
 
210
-                $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
210
+                $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
211 211
                 $cmd = '';
212
-            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
212
+            } elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
213 213
                 $modifiers = substr($modifiers, strlen($match[0]));
214
-                $result[]=array('cmd'=>'math','opt'=>'%s' . $c . $match[0]);
214
+                $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]);
215 215
                 $cmd = '';
216
-            } elseif ($c==='(' || $c==='=') {
216
+            } elseif ($c === '(' || $c === '=') {
217 217
                 $modifiers = $m1 = trim($modifiers);
218 218
                 $delim     = $this->_getDelim($c, $modifiers);
219 219
                 $opt       = $this->_getOpt($c, $delim, $modifiers);
220 220
                 $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers));
221 221
                 $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]";
222 222
 
223
-                $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo);
223
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo);
224 224
 
225 225
                 $cmd = '';
226
-            } elseif ($c==':') {
226
+            } elseif ($c == ':') {
227 227
                 $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]";
228
-                if ($cmd!=='') {
229
-                    $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
228
+                if ($cmd !== '') {
229
+                    $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
230 230
                 }
231 231
 
232 232
                 $cmd = '';
233
-            } elseif (trim($modifiers)=='' && trim($cmd)!=='') {
233
+            } elseif (trim($modifiers) == '' && trim($cmd) !== '') {
234 234
                 $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]";
235 235
                 $cmd .= $c;
236
-                $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo);
236
+                $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo);
237 237
 
238 238
                 break;
239 239
             } else {
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
         }
271 271
         $_ = explode(',', $this->condModifiers);
272 272
         if (in_array($lastKey, $_)) {
273
-            $modifiers[] = array('cmd'=>'then','opt'=>'1');
274
-            $modifiers[] = array('cmd'=>'else','opt'=>'0');
273
+            $modifiers[] = array('cmd'=>'then', 'opt'=>'1');
274
+            $modifiers[] = array('cmd'=>'else', 'opt'=>'0');
275 275
         }
276 276
 
277 277
         foreach ($modifiers as $i=>$a) {
@@ -282,17 +282,17 @@  discard block
 block discarded – undo
282 282
     }
283 283
 
284 284
     // Parser: modifier detection and eXtended processing if needed
285
-    public function Filter($key, $value, $cmd, $opt='')
285
+    public function Filter($key, $value, $cmd, $opt = '')
286 286
     {
287 287
         $modx = evolutionCMS();
288 288
 
289
-        if ($key==='documentObject') {
289
+        if ($key === 'documentObject') {
290 290
             $value = $modx->documentIdentifier;
291 291
         }
292 292
         $cmd = $this->parseDocumentSource($cmd);
293 293
         if (preg_match('@^[1-9][/0-9]*$@', $cmd)) {
294
-            if (strpos($cmd, '/')!==false) {
295
-                $cmd = $this->substr($cmd, strrpos($cmd, '/')+1);
294
+            if (strpos($cmd, '/') !== false) {
295
+                $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1);
296 296
             }
297 297
             $opt = $cmd;
298 298
             $cmd = 'id';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         }
308 308
 
309 309
         $cmd = strtolower($cmd);
310
-        if ($this->elmName!=='') {
310
+        if ($this->elmName !== '') {
311 311
             $value = $this->getValueFromElement($key, $value, $cmd, $opt);
312 312
         } else {
313 313
             $value = $this->getValueFromPreset($key, $value, $cmd, $opt);
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 
321 321
     public function isEmpty($cmd, $value)
322 322
     {
323
-        if ($value!=='') {
323
+        if ($value !== '') {
324 324
             return false;
325 325
         }
326 326
 
327
-        $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
327
+        $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary');
328 328
         if (in_array($cmd, $_)) {
329 329
             return false;
330 330
         } else {
@@ -356,56 +356,56 @@  discard block
 block discarded – undo
356 356
             case 'eq':
357 357
             case 'is':
358 358
             case 'equals':
359
-                $this->condition[] = (int)($value == $opt); break;
359
+                $this->condition[] = (int) ($value == $opt); break;
360 360
             case 'neq':
361 361
             case 'ne':
362 362
             case 'notequals':
363 363
             case 'isnot':
364 364
             case 'isnt':
365 365
             case 'not':
366
-                $this->condition[] = (int)($value != $opt);break;
366
+                $this->condition[] = (int) ($value != $opt); break;
367 367
             case '%':
368
-                $this->condition[] = (int)($value%$opt==0);break;
368
+                $this->condition[] = (int) ($value % $opt == 0); break;
369 369
             case 'isempty':
370
-                $this->condition[] = (int)(empty($value)); break;
370
+                $this->condition[] = (int) (empty($value)); break;
371 371
             case 'isntempty':
372 372
             case 'isnotempty':
373
-                $this->condition[] = (int)(!empty($value)); break;
373
+                $this->condition[] = (int) (!empty($value)); break;
374 374
             case '>=':
375 375
             case 'gte':
376 376
             case 'eg':
377 377
             case 'isgte':
378
-                $this->condition[] = (int)($value >= $opt);break;
378
+                $this->condition[] = (int) ($value >= $opt); break;
379 379
             case '<=':
380 380
             case 'lte':
381 381
             case 'el':
382 382
             case 'islte':
383
-                $this->condition[] = (int)($value <= $opt);break;
383
+                $this->condition[] = (int) ($value <= $opt); break;
384 384
             case '>':
385 385
             case 'gt':
386 386
             case 'greaterthan':
387 387
             case 'isgreaterthan':
388 388
             case 'isgt':
389
-                $this->condition[] = (int)($value > $opt);break;
389
+                $this->condition[] = (int) ($value > $opt); break;
390 390
             case '<':
391 391
             case 'lt':
392 392
             case 'lowerthan':
393 393
             case 'islowerthan':
394 394
             case 'islt':
395
-                $this->condition[] = (int)($value < $opt);break;
395
+                $this->condition[] = (int) ($value < $opt); break;
396 396
             case 'find':
397
-                $this->condition[] = (int)(strpos($value, $opt)!==false);break;
397
+                $this->condition[] = (int) (strpos($value, $opt) !== false); break;
398 398
             case 'inarray':
399 399
             case 'in_array':
400 400
             case 'in':
401 401
                 $opt = explode(',', $opt);
402
-                $this->condition[] = (int)(in_array($value, $opt)!==false);break;
402
+                $this->condition[] = (int) (in_array($value, $opt) !== false); break;
403 403
             case 'wildcard_match':
404 404
             case 'wcard_match':
405 405
             case 'wildcard':
406 406
             case 'wcard':
407 407
             case 'fnmatch':
408
-                $this->condition[] = (int)(fnmatch($opt, $value)!==false);break;
408
+                $this->condition[] = (int) (fnmatch($opt, $value) !== false); break;
409 409
             case 'is_file':
410 410
             case 'is_dir':
411 411
             case 'file_exists':
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
                 } else {
417 417
                     $path = $opt;
418 418
                 }
419
-                if (strpos($path, MODX_MANAGER_PATH)!==false) {
419
+                if (strpos($path, MODX_MANAGER_PATH) !== false) {
420 420
                     exit('Can not read core path');
421 421
                 }
422
-                if (strpos($path, $modx->config['base_path'])===false) {
422
+                if (strpos($path, $modx->config['base_path']) === false) {
423 423
                     $path = ltrim($path, '/');
424 424
                 }
425
-                $this->condition[] = (int)($cmd($path)!==false);break;
425
+                $this->condition[] = (int) ($cmd($path) !== false); break;
426 426
             case 'is_image':
427 427
                 if (!$opt) {
428 428
                     $path = $value;
@@ -430,16 +430,16 @@  discard block
 block discarded – undo
430 430
                     $path = $opt;
431 431
                 }
432 432
                 if (!is_file($path)) {
433
-                    $this->condition[]='0';
433
+                    $this->condition[] = '0';
434 434
                     break;
435 435
                 }
436 436
                 $_ = getimagesize($path);
437
-                $this->condition[] = (int)($_[0]);break;
437
+                $this->condition[] = (int) ($_[0]); break;
438 438
             case 'regex':
439 439
             case 'preg':
440 440
             case 'preg_match':
441 441
             case 'isinrole':
442
-            $this->condition[] = (int)(preg_match($opt, $value));break;
442
+            $this->condition[] = (int) (preg_match($opt, $value)); break;
443 443
             case 'ir':
444 444
             case 'memberof':
445 445
             case 'mo':
@@ -447,27 +447,27 @@  discard block
 block discarded – undo
447 447
                 $this->condition[] = $this->includeMdfFile('memberof');
448 448
                 break;
449 449
             case 'or':
450
-                $this->condition[] = '||';break;
450
+                $this->condition[] = '||'; break;
451 451
             case 'and':
452
-                $this->condition[] = '&&';break;
452
+                $this->condition[] = '&&'; break;
453 453
             case 'show':
454 454
             case 'this':
455 455
                 $conditional = implode(' ', $this->condition);
456
-                $isvalid = (int)(eval("return ({$conditional});"));
456
+                $isvalid = (int) (eval("return ({$conditional});"));
457 457
                 if ($isvalid) {
458 458
                     return $this->srcValue;
459 459
                 }
460 460
                 return null;
461 461
             case 'then':
462 462
                 $conditional = implode(' ', $this->condition);
463
-                $isvalid = (int)eval("return ({$conditional});");
463
+                $isvalid = (int) eval("return ({$conditional});");
464 464
                 if ($isvalid) {
465 465
                     return $opt;
466 466
                 }
467 467
                 return null;
468 468
             case 'else':
469 469
                 $conditional = implode(' ', $this->condition);
470
-                $isvalid = (int)eval("return ({$conditional});");
470
+                $isvalid = (int) eval("return ({$conditional});");
471 471
                 if (!$isvalid) {
472 472
                     return $opt;
473 473
                 }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 $raw = explode('&', $opt);
478 478
                 $map = array();
479 479
                 $c = count($raw);
480
-                for ($m=0; $m<$c; $m++) {
480
+                for ($m = 0; $m < $c; $m++) {
481 481
                     $mi = explode('=', $raw[$m], 2);
482 482
                     $map[$mi[0]] = $mi[1];
483 483
                 }
@@ -510,18 +510,18 @@  discard block
 block discarded – undo
510 510
             case 'html_encode':
511 511
                 return preg_replace('/&amp;(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset']));
512 512
             case 'spam_protect':
513
-                return str_replace(array('@','.'), array('&#64;','&#46;'), $value);
513
+                return str_replace(array('@', '.'), array('&#64;', '&#46;'), $value);
514 514
             case 'strip':
515
-                if ($opt==='') {
515
+                if ($opt === '') {
516 516
                     $opt = ' ';
517 517
                 }
518 518
                 return preg_replace('/[\n\r\t\s]+/', $opt, $value);
519 519
             case 'strip_linefeeds':
520
-                return str_replace(array("\n","\r"), '', $value);
520
+                return str_replace(array("\n", "\r"), '', $value);
521 521
             case 'notags':
522 522
             case 'strip_tags':
523 523
             case 'remove_html':
524
-                if ($opt!=='') {
524
+                if ($opt !== '') {
525 525
                     $param = array();
526 526
                     foreach (explode(',', $opt) as $v) {
527 527
                         $v = trim($v, '</> ');
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
                 } else {
532 532
                     $params = '';
533 533
                 }
534
-                if (!strpos($params, '<br>')===false) {
534
+                if (!strpos($params, '<br>') === false) {
535 535
                     $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value);
536 536
                     $value = preg_replace('@<br[ /]*>@', "\n", $value);
537 537
                 }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             case 'encode_url':
542 542
                 return urlencode($value);
543 543
             case 'base64_decode':
544
-                if ($opt!=='false') {
544
+                if ($opt !== 'false') {
545 545
                     $opt = true;
546 546
                 } else {
547 547
                     $opt = false;
@@ -578,12 +578,12 @@  discard block
 block discarded – undo
578 578
                 return implode(' ', $_);
579 579
             case 'zenhan':
580 580
                 if (empty($opt)) {
581
-                    $opt='VKas';
581
+                    $opt = 'VKas';
582 582
                 }
583 583
                 return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
584 584
             case 'hanzen':
585 585
                 if (empty($opt)) {
586
-                    $opt='VKAS';
586
+                    $opt = 'VKAS';
587 587
                 }
588 588
                 return mb_convert_kana($value, $opt, $modx->config['modx_charset']);
589 589
             case 'str_shuffle':
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
                 $value = preg_replace('/\r/', '', $value);
610 610
                 return count(preg_split('/\n+/', $value));
611 611
             case 'strpos':
612
-                if ($opt!=0&&empty($opt)) {
612
+                if ($opt != 0 && empty($opt)) {
613 613
                     return $value;
614 614
                 }
615 615
                 return $this->strpos($value, $opt);
616 616
             case 'wordwrap':
617 617
                 // default: 70
618
-                  $wrapat = (int)$opt > 0 ? (int)$opt : 70;
618
+                  $wrapat = (int) $opt > 0 ? (int) $opt : 70;
619 619
                 if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
620 620
                     return $this->includeMdfFile('wordwrap');
621 621
                 } else {
@@ -624,12 +624,12 @@  discard block
 block discarded – undo
624 624
                 // no break
625 625
             case 'wrap_text':
626 626
                 $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70;
627
-                if ($modx->config['manager_language']==='japanese-utf8') {
627
+                if ($modx->config['manager_language'] === 'japanese-utf8') {
628 628
                     $chunk = array();
629
-                    $bt='';
630
-                    while ($bt!=$value) {
629
+                    $bt = '';
630
+                    while ($bt != $value) {
631 631
                         $bt = $value;
632
-                        if ($this->strlen($value)<$width) {
632
+                        if ($this->strlen($value) < $width) {
633 633
                             $chunk[] = $value;
634 634
                             break;
635 635
                         }
@@ -645,31 +645,31 @@  discard block
 block discarded – undo
645 645
                 if (empty($opt)) {
646 646
                     break;
647 647
                 }
648
-                if (strpos($opt, ',')!==false) {
648
+                if (strpos($opt, ',') !== false) {
649 649
                     list($b, $e) = explode(',', $opt, 2);
650
-                    return $this->substr($value, $b, (int)$e);
650
+                    return $this->substr($value, $b, (int) $e);
651 651
                 } else {
652 652
                     return $this->substr($value, $opt);
653 653
                 }
654 654
                 // no break
655 655
             case 'limit':
656 656
             case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html
657
-                if (strpos($opt, '+')!==false) {
657
+                if (strpos($opt, '+') !== false) {
658 658
                     list($len, $str) = explode('+', $opt, 2);
659 659
                 } else {
660 660
                     $len = $opt;
661 661
                     $str = '';
662 662
                 }
663
-                if ($len==='') {
663
+                if ($len === '') {
664 664
                     $len = 100;
665 665
                 }
666 666
                 if (abs($len) > $this->strlen($value)) {
667
-                    $str ='';
667
+                    $str = '';
668 668
                 }
669 669
                 if (preg_match('/^[1-9][0-9]*$/', $len)) {
670
-                    return $this->substr($value, 0, $len) . $str;
670
+                    return $this->substr($value, 0, $len).$str;
671 671
                 } elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) {
672
-                    return $str . $this->substr($value, $len);
672
+                    return $str.$this->substr($value, $len);
673 673
                 }
674 674
                 break;
675 675
             case 'summary':
@@ -678,41 +678,41 @@  discard block
 block discarded – undo
678 678
                 return $this->includeMdfFile('summary');
679 679
             case 'replace':
680 680
             case 'str_replace':
681
-                if (empty($opt) || strpos($opt, ',')===false) {
681
+                if (empty($opt) || strpos($opt, ',') === false) {
682 682
                     break;
683 683
                 }
684
-                if (substr_count($opt, ',') ==1) {
684
+                if (substr_count($opt, ',') == 1) {
685 685
                     $delim = ',';
686
-                } elseif (substr_count($opt, '|') ==1) {
686
+                } elseif (substr_count($opt, '|') == 1) {
687 687
                     $delim = '|';
688
-                } elseif (substr_count($opt, '=>')==1) {
688
+                } elseif (substr_count($opt, '=>') == 1) {
689 689
                     $delim = '=>';
690
-                } elseif (substr_count($opt, '/') ==1) {
690
+                } elseif (substr_count($opt, '/') == 1) {
691 691
                     $delim = '/';
692 692
                 } else {
693 693
                     break;
694 694
                 }
695 695
                 list($s, $r) = explode($delim, $opt);
696
-                if ($value!=='') {
696
+                if ($value !== '') {
697 697
                     return str_replace($s, $r, $value);
698 698
                 }
699 699
                 break;
700 700
             case 'replace_to':
701 701
             case 'tpl':
702
-                if ($value!=='') {
703
-                    return str_replace(array('[+value+]','[+output+]','{value}','%s'), $value, $opt);
702
+                if ($value !== '') {
703
+                    return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt);
704 704
                 }
705 705
                 break;
706 706
             case 'eachtpl':
707 707
                 $value = explode('||', $value);
708 708
                 $_ = array();
709 709
                 foreach ($value as $v) {
710
-                    $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'), $v, $opt);
710
+                    $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt);
711 711
                 }
712 712
                 return implode("\n", $_);
713 713
             case 'array_pop':
714 714
             case 'array_shift':
715
-                if (strpos($value, '||')!==false) {
715
+                if (strpos($value, '||') !== false) {
716 716
                     $delim = '||';
717 717
                 } else {
718 718
                     $delim = ',';
@@ -720,43 +720,43 @@  discard block
 block discarded – undo
720 720
                 return $cmd(explode($delim, $value));
721 721
             case 'preg_replace':
722 722
             case 'regex_replace':
723
-                if (empty($opt) || strpos($opt, ',')===false) {
723
+                if (empty($opt) || strpos($opt, ',') === false) {
724 724
                     break;
725 725
                 }
726 726
                 list($s, $r) = explode(',', $opt, 2);
727
-                if ($value!=='') {
727
+                if ($value !== '') {
728 728
                     return preg_replace($s, $r, $value);
729 729
                 }
730 730
                 break;
731 731
             case 'cat':
732 732
             case 'concatenate':
733 733
             case '.':
734
-                if ($value!=='') {
735
-                    return $value . $opt;
734
+                if ($value !== '') {
735
+                    return $value.$opt;
736 736
                 }
737 737
                 break;
738 738
             case 'sprintf':
739 739
             case 'string_format':
740
-                if ($value!=='') {
740
+                if ($value !== '') {
741 741
                     return sprintf($opt, $value);
742 742
                 }
743 743
                 break;
744 744
             case 'number_format':
745
-                    if ($opt=='') {
745
+                    if ($opt == '') {
746 746
                         $opt = 0;
747 747
                     }
748 748
                     return number_format($value, $opt);
749 749
             case 'money_format':
750 750
                     setlocale(LC_MONETARY, setlocale(LC_TIME, 0));
751
-                    if ($value!=='') {
752
-                        return money_format($opt, (double)$value);
751
+                    if ($value !== '') {
752
+                        return money_format($opt, (double) $value);
753 753
                     }
754 754
                     break;
755 755
             case 'tobool':
756 756
                 return boolval($value);
757 757
             case 'nl2lf':
758
-                if ($value!=='') {
759
-                    return str_replace(array("\r\n","\n", "\r"), '\n', $value);
758
+                if ($value !== '') {
759
+                    return str_replace(array("\r\n", "\n", "\r"), '\n', $value);
760 760
                 }
761 761
                 break;
762 762
             case 'br2nl':
@@ -765,17 +765,17 @@  discard block
 block discarded – undo
765 765
                 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
766 766
                     return nl2br($value);
767 767
                 }
768
-                if ($opt!=='') {
768
+                if ($opt !== '') {
769 769
                     $opt = trim($opt);
770 770
                     $opt = strtolower($opt);
771
-                    if ($opt==='false') {
771
+                    if ($opt === 'false') {
772 772
                         $opt = false;
773
-                    } elseif ($opt==='0') {
773
+                    } elseif ($opt === '0') {
774 774
                         $opt = false;
775 775
                     } else {
776 776
                         $opt = true;
777 777
                     }
778
-                } elseif (isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') {
778
+                } elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') {
779 779
                     $opt = false;
780 780
                 } else {
781 781
                     $opt = true;
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
             case 'ltrim':
785 785
             case 'rtrim':
786 786
             case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html
787
-                if ($opt==='') {
787
+                if ($opt === '') {
788 788
                     return $cmd($value);
789 789
                 } else {
790 790
                     return $cmd($value, $opt);
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
                 if (!preg_match('@^[0-9]+$@', $value)) {
807 807
                     $value = strtotime($value);
808 808
                 }
809
-                if (strpos($opt, '%')!==false) {
810
-                    return strftime($opt, 0+$value);
809
+                if (strpos($opt, '%') !== false) {
810
+                    return strftime($opt, 0 + $value);
811 811
                 } else {
812
-                    return date($opt, 0+$value);
812
+                    return date($opt, 0 + $value);
813 813
                 }
814 814
                     // no break
815 815
             case 'time':
@@ -819,12 +819,12 @@  discard block
 block discarded – undo
819 819
                 if (!preg_match('@^[0-9]+$@', $value)) {
820 820
                     $value = strtotime($value);
821 821
                 }
822
-                return strftime($opt, 0+$value);
822
+                return strftime($opt, 0 + $value);
823 823
             case 'strtotime':
824 824
                 return strtotime($value);
825 825
             #####  mathematical function
826 826
             case 'toint':
827
-                return (int)$value;
827
+                return (int) $value;
828 828
             case 'tofloat':
829 829
                 return floatval($value);
830 830
             case 'round':
@@ -841,27 +841,27 @@  discard block
 block discarded – undo
841 841
                 return $cmd($value);
842 842
             case 'math':
843 843
             case 'calc':
844
-                $value = (int)$value;
844
+                $value = (int) $value;
845 845
                 if (empty($value)) {
846 846
                     $value = '0';
847 847
                 }
848
-                $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'), '?', $opt);
848
+                $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt);
849 849
                 $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter);
850
-                if (strpos($filter, '?')===false) {
850
+                if (strpos($filter, '?') === false) {
851 851
                     $filter = "?{$filter}";
852 852
                 }
853 853
                 $filter = str_replace('?', $value, $filter);
854 854
                 return eval("return {$filter};");
855 855
             case 'count':
856
-                if ($value=='') {
856
+                if ($value == '') {
857 857
                     return 0;
858 858
                 }
859 859
                 $value = explode(',', $value);
860 860
                 return count($value);
861 861
             case 'sort':
862 862
             case 'rsort':
863
-                if (strpos($value, "\n")!==false) {
864
-                    $delim="\n";
863
+                if (strpos($value, "\n") !== false) {
864
+                    $delim = "\n";
865 865
                 } else {
866 866
                     $delim = ',';
867 867
                 }
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
             case 'privatemgr':
915 915
             case 'content_dispo':
916 916
             case 'hidemenu':
917
-                if ($cmd==='contenttype') {
917
+                if ($cmd === 'contenttype') {
918 918
                     $cmd = 'contentType';
919 919
                 }
920 920
                 return $this->getDocumentObject($value, $cmd);
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
                 return $modx->getField($opt, $value);
938 938
             case 'children':
939 939
             case 'childids':
940
-                if ($value=='') {
940
+                if ($value == '') {
941 941
                     $value = 0;
942 942
                 } // 値がない場合はルートと見なす
943 943
                 $published = 1;
944
-                if ($opt=='') {
944
+                if ($opt == '') {
945 945
                     $opt = 'page';
946 946
                 }
947 947
                 $_ = explode(',', $opt);
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
                 $where = implode(' AND ', $where);
960 960
                 $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where);
961 961
                 $result = array();
962
-                foreach ((array)$children as $child) {
962
+                foreach ((array) $children as $child) {
963 963
                     $result[] = $child['id'];
964 964
                 }
965 965
                 return implode(',', $result);
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
                     return $value;
1020 1020
                 }
1021 1021
                 $value = realpath($value);
1022
-                if (strpos($value, MODX_MANAGER_PATH)!==false) {
1022
+                if (strpos($value, MODX_MANAGER_PATH) !== false) {
1023 1023
                     exit('Can not read core file');
1024 1024
                 }
1025 1025
                 $ext = strtolower(substr($value, -4));
1026
-                if ($ext==='.php') {
1026
+                if ($ext === '.php') {
1027 1027
                     exit('Can not read php file');
1028 1028
                 }
1029
-                if ($ext==='.cgi') {
1029
+                if ($ext === '.cgi') {
1030 1030
                     exit('Can not read cgi file');
1031 1031
                 }
1032 1032
                 return file_get_contents($value);
@@ -1043,11 +1043,11 @@  discard block
 block discarded – undo
1043 1043
                 $filename = trim($filename, '/');
1044 1044
 
1045 1045
                 $opt = trim($opt, '/');
1046
-                if ($opt!=='') {
1046
+                if ($opt !== '') {
1047 1047
                     $opt .= '/';
1048 1048
                 }
1049 1049
 
1050
-                $filename = MODX_BASE_PATH . $opt . $filename;
1050
+                $filename = MODX_BASE_PATH.$opt.$filename;
1051 1051
 
1052 1052
                 if (is_file($filename)) {
1053 1053
                     clearstatcache();
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
                     return $opt;
1107 1107
                 } break;
1108 1108
             case 'datagrid':
1109
-                include_once(MODX_CORE_PATH . 'controls/datagrid.class.php');
1109
+                include_once(MODX_CORE_PATH.'controls/datagrid.class.php');
1110 1110
                 $grd = new DataGrid(null, trim($value));
1111 1111
                 $grd->itemStyle = '';
1112 1112
                 $grd->altItemStyle = '';
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
                 } else {
1117 1117
                     $_ = $pos;
1118 1118
                 }
1119
-                $grd->cdelim = strpos($_, "\t")!==false ? 'tab' : ',';
1119
+                $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ',';
1120 1120
                 return $grd->render();
1121 1121
             case 'rotate':
1122 1122
             case 'evenodd':
1123
-                if (strpos($opt, ',')===false) {
1123
+                if (strpos($opt, ',') === false) {
1124 1124
                     $opt = 'odd,even';
1125 1125
                 }
1126 1126
                 $_ = explode(',', $opt);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
                 if (empty($opt)) {
1154 1154
                     $opt = 560;
1155 1155
                 }
1156
-                $h = round($opt*0.5625);
1156
+                $h = round($opt * 0.5625);
1157 1157
                 $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>';
1158 1158
                 return sprintf($tpl, $opt, $h, $value);
1159 1159
             //case 'youtube4x3':%s*0.75+25
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
         $key = $this->key;
1192 1192
         $value  = $this->value;
1193 1193
         $opt    = $this->opt;
1194
-        return include(MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php");
1194
+        return include(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php");
1195 1195
     }
1196 1196
 
1197 1197
     public function getValueFromElement($key, $value, $cmd, $opt)
@@ -1207,13 +1207,13 @@  discard block
 block discarded – undo
1207 1207
                 $row = $modx->db->getRow($result);
1208 1208
                 $php = $row['snippet'];
1209 1209
             } elseif ($total == 0) {
1210
-                $assets_path = MODX_BASE_PATH . 'assets/';
1211
-                if (is_file($assets_path . "modifiers/mdf_{$cmd}.inc.php")) {
1212
-                    $modifiers_path = $assets_path . "modifiers/mdf_{$cmd}.inc.php";
1213
-                } elseif (is_file($assets_path . "plugins/phx/modifiers/{$cmd}.phx.php")) {
1214
-                    $modifiers_path = $assets_path . "plugins/phx/modifiers/{$cmd}.phx.php";
1215
-                } elseif (is_file(MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php")) {
1216
-                    $modifiers_path = MODX_CORE_PATH . "extenders/modifiers/mdf_{$cmd}.inc.php";
1210
+                $assets_path = MODX_BASE_PATH.'assets/';
1211
+                if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) {
1212
+                    $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php";
1213
+                } elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) {
1214
+                    $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php";
1215
+                } elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) {
1216
+                    $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php";
1217 1217
                 } else {
1218 1218
                     $modifiers_path = false;
1219 1219
                 }
@@ -1221,17 +1221,17 @@  discard block
 block discarded – undo
1221 1221
                 if ($modifiers_path !== false) {
1222 1222
                     $php = @file_get_contents($modifiers_path);
1223 1223
                     $php = trim($php);
1224
-                    if (substr($php, 0, 5)==='<?php') {
1224
+                    if (substr($php, 0, 5) === '<?php') {
1225 1225
                         $php = substr($php, 6);
1226 1226
                     }
1227
-                    if (substr($php, 0, 2)==='<?') {
1227
+                    if (substr($php, 0, 2) === '<?') {
1228 1228
                         $php = substr($php, 3);
1229 1229
                     }
1230
-                    if (substr($php, -2)==='?>') {
1230
+                    if (substr($php, -2) === '?>') {
1231 1231
                         $php = substr($php, 0, -2);
1232 1232
                     }
1233
-                    if ($this->elmName!=='') {
1234
-                        $modx->snippetCache[$this->elmName . 'Props'] = '';
1233
+                    if ($this->elmName !== '') {
1234
+                        $modx->snippetCache[$this->elmName.'Props'] = '';
1235 1235
                     }
1236 1236
                 } else {
1237 1237
                     $php = false;
@@ -1239,15 +1239,15 @@  discard block
 block discarded – undo
1239 1239
             } else {
1240 1240
                 $php = false;
1241 1241
             }
1242
-            if ($this->elmName!=='') {
1243
-                $modx->snippetCache[$this->elmName]= $php;
1242
+            if ($this->elmName !== '') {
1243
+                $modx->snippetCache[$this->elmName] = $php;
1244 1244
             }
1245 1245
         }
1246
-        if ($php==='') {
1247
-            $php=false;
1246
+        if ($php === '') {
1247
+            $php = false;
1248 1248
         }
1249 1249
 
1250
-        if ($php===false) {
1250
+        if ($php === false) {
1251 1251
             $html = $modx->getChunk($this->elmName);
1252 1252
         } else {
1253 1253
             $html = false;
@@ -1267,56 +1267,56 @@  discard block
 block discarded – undo
1267 1267
             $this->vars['options'] = & $opt;
1268 1268
             $custom = eval($php);
1269 1269
             $msg = ob_get_contents();
1270
-            if ($value===$this->bt) {
1271
-                $value = $msg . $custom;
1270
+            if ($value === $this->bt) {
1271
+                $value = $msg.$custom;
1272 1272
             }
1273 1273
             ob_end_clean();
1274
-        } elseif ($html!==false && isset($value) && $value!=='') {
1275
-            $html = str_replace(array($self,'[+value+]'), $value, $html);
1276
-            $value = str_replace(array('[+options+]','[+param+]'), $opt, $html);
1274
+        } elseif ($html !== false && isset($value) && $value !== '') {
1275
+            $html = str_replace(array($self, '[+value+]'), $value, $html);
1276
+            $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html);
1277 1277
         } else {
1278 1278
             return false;
1279 1279
         }
1280 1280
 
1281
-        if ($php===false && $html===false && $value!==''
1282
-           && (strpos($cmd, '[+value+]')!==false || strpos($cmd, $self)!==false)) {
1283
-            $value = str_replace(array('[+value+]',$self), $value, $cmd);
1281
+        if ($php === false && $html === false && $value !== ''
1282
+           && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) {
1283
+            $value = str_replace(array('[+value+]', $self), $value, $cmd);
1284 1284
         }
1285 1285
         return $value;
1286 1286
     }
1287 1287
 
1288
-    public function parseDocumentSource($content='')
1288
+    public function parseDocumentSource($content = '')
1289 1289
     {
1290 1290
         $modx = evolutionCMS();
1291 1291
 
1292
-        if (strpos($content, '[')===false && strpos($content, '{')===false) {
1292
+        if (strpos($content, '[') === false && strpos($content, '{') === false) {
1293 1293
             return $content;
1294 1294
         }
1295 1295
 
1296 1296
         if (!$modx->maxParserPasses) {
1297 1297
             $modx->maxParserPasses = 10;
1298 1298
         }
1299
-        $bt='';
1300
-        $i=0;
1301
-        while ($bt!==$content) {
1299
+        $bt = '';
1300
+        $i = 0;
1301
+        while ($bt !== $content) {
1302 1302
             $bt = $content;
1303
-            if (strpos($content, '[*')!==false && $modx->documentIdentifier) {
1303
+            if (strpos($content, '[*') !== false && $modx->documentIdentifier) {
1304 1304
                 $content = $modx->mergeDocumentContent($content);
1305 1305
             }
1306
-            if (strpos($content, '[(')!==false) {
1306
+            if (strpos($content, '[(') !== false) {
1307 1307
                 $content = $modx->mergeSettingsContent($content);
1308 1308
             }
1309
-            if (strpos($content, '{{')!==false) {
1309
+            if (strpos($content, '{{') !== false) {
1310 1310
                 $content = $modx->mergeChunkContent($content);
1311 1311
             }
1312
-            if (strpos($content, '[!')!==false) {
1313
-                $content = str_replace(array('[!','!]'), array('[[',']]'), $content);
1312
+            if (strpos($content, '[!') !== false) {
1313
+                $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content);
1314 1314
             }
1315
-            if (strpos($content, '[[')!==false) {
1315
+            if (strpos($content, '[[') !== false) {
1316 1316
                 $content = $modx->evalSnippets($content);
1317 1317
             }
1318 1318
 
1319
-            if ($content===$bt) {
1319
+            if ($content === $bt) {
1320 1320
                 break;
1321 1321
             }
1322 1322
             if ($modx->maxParserPasses < $i) {
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
         return $content;
1328 1328
     }
1329 1329
 
1330
-    public function getDocumentObject($target='', $field='pagetitle')
1330
+    public function getDocumentObject($target = '', $field = 'pagetitle')
1331 1331
     {
1332 1332
         $modx = evolutionCMS();
1333 1333
 
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
             $target = $modx->config['site_start'];
1337 1337
         }
1338 1338
         if (preg_match('@^[1-9][0-9]*$@', $target)) {
1339
-            $method='id';
1339
+            $method = 'id';
1340 1340
         } else {
1341 1341
             $method = 'alias';
1342 1342
         }
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
             $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct');
1346 1346
         }
1347 1347
 
1348
-        if ($this->documentObject[$target]['publishedon']==='0') {
1348
+        if ($this->documentObject[$target]['publishedon'] === '0') {
1349 1349
             return '';
1350 1350
         } elseif (isset($this->documentObject[$target][$field])) {
1351 1351
             if (is_array($this->documentObject[$target][$field])) {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 
1362 1362
     public function setPlaceholders($value = '', $key = '', $path = '')
1363 1363
     {
1364
-        if ($path!=='') {
1364
+        if ($path !== '') {
1365 1365
             $key = "{$path}.{$key}";
1366 1366
         }
1367 1367
         if (is_array($value)) {
@@ -1389,14 +1389,14 @@  discard block
 block discarded – undo
1389 1389
             $l = $this->strlen($str);
1390 1390
         }
1391 1391
         if (function_exists('mb_substr')) {
1392
-            if (strpos($str, "\r")!==false) {
1393
-                $str = str_replace(array("\r\n","\r"), "\n", $str);
1392
+            if (strpos($str, "\r") !== false) {
1393
+                $str = str_replace(array("\r\n", "\r"), "\n", $str);
1394 1394
             }
1395 1395
             return mb_substr($str, $s, $l, $modx->config['modx_charset']);
1396 1396
         }
1397 1397
         return substr($str, $s, $l);
1398 1398
     }
1399
-    public function strpos($haystack, $needle, $offset=0)
1399
+    public function strpos($haystack, $needle, $offset = 0)
1400 1400
     {
1401 1401
         $modx = evolutionCMS();
1402 1402
         if (function_exists('mb_strpos')) {
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
     public function ucfirst($str)
1430 1430
     {
1431 1431
         if (function_exists('mb_strtoupper')) {
1432
-            return mb_strtoupper($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str));
1432
+            return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1433 1433
         }
1434 1434
         return ucfirst($str);
1435 1435
     }
1436 1436
     public function lcfirst($str)
1437 1437
     {
1438 1438
         if (function_exists('mb_strtolower')) {
1439
-            return mb_strtolower($this->substr($str, 0, 1)) . $this->substr($str, 1, $this->strlen($str));
1439
+            return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str));
1440 1440
         }
1441 1441
         return lcfirst($str);
1442 1442
     }
@@ -1462,14 +1462,14 @@  discard block
 block discarded – undo
1462 1462
     {
1463 1463
         return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
1464 1464
     }
1465
-    public function strip_tags($value, $params='')
1465
+    public function strip_tags($value, $params = '')
1466 1466
     {
1467 1467
         $modx = evolutionCMS();
1468 1468
 
1469
-        if (stripos($params, 'style')===false && stripos($value, '</style>')!==false) {
1469
+        if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) {
1470 1470
             $value = preg_replace('@<style.*?>.*?</style>@is', '', $value);
1471 1471
         }
1472
-        if (stripos($params, 'script')===false && stripos($value, '</script>')!==false) {
1472
+        if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) {
1473 1473
             $value = preg_replace('@<script.*?>.*?</script>@is', '', $value);
1474 1474
         }
1475 1475
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -194,7 +194,8 @@  discard block
 block discarded – undo
194 194
             $c = substr($modifiers, 0, 1);
195 195
             $modifiers = substr($modifiers, 1);
196 196
 
197
-            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>=
197
+            if ($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) {
198
+// :=, :!=, :<=, :>=, :!<=, :!>=
198 199
                 $c = substr($modifiers, strlen($match[1]), 1);
199 200
                 $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]";
200 201
                 if ($c==='(') {
@@ -209,7 +210,8 @@  discard block
 block discarded – undo
209 210
 
210 211
                 $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo);
211 212
                 $cmd = '';
212
-            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ...
213
+            } elseif (in_array($c, array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) {
214
+// :+3, :-3, :*3 ...
213 215
                 $modifiers = substr($modifiers, strlen($match[0]));
214 216
                 $result[]=array('cmd'=>'math','opt'=>'%s' . $c . $match[0]);
215 217
                 $cmd = '';
Please login to merge, or discard this patch.
manager/includes/tmplvars.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -382,7 +382,7 @@
 block discarded – undo
382 382
 } // end renderFormElement function
383 383
 
384 384
 /**
385
- * @param string|array|mysqli_result $v
385
+ * @param string $v
386 386
  * @return array
387 387
  */
388 388
 function ParseIntputOptions($v)
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,22 +33,22 @@  discard block
 block discarded – undo
33 33
 
34 34
             case "text": // handler for regular text boxes
35 35
             case "rawtext": // non-htmlentity converted text boxes
36
-                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" />';
36
+                $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" />';
37 37
                 break;
38 38
             case "email": // handles email input fields
39
-                $field_html .= '<input type="email" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%"/>';
39
+                $field_html .= '<input type="email" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%"/>';
40 40
                 break;
41 41
             case "number": // handles the input of numbers
42
-                $field_html .= '<input type="number" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' tvtype="' . $field_type . '" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
42
+                $field_html .= '<input type="number" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' tvtype="'.$field_type.'" onchange="documentDirty=true;" style="width:100%" onkeyup="this.value=this.value.replace(/[^\d-,.+]/,\'\')"/>';
43 43
                 break;
44 44
             case "textareamini": // handler for textarea mini boxes
45
-                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
45
+                $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="5" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>';
46 46
                 break;
47 47
             case "textarea": // handler for textarea boxes
48 48
             case "rawtextarea": // non-htmlentity convertex textarea boxes
49 49
             case "htmlarea": // handler for textarea boxes (deprecated)
50 50
             case "richtext": // handler for textarea boxes
51
-                $field_html .= '<textarea id="tv' . $field_id . '" name="tv' . $field_id . '" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">' . $modx->htmlspecialchars($field_value) . '</textarea>';
51
+                $field_html .= '<textarea id="tv'.$field_id.'" name="tv'.$field_id.'" cols="40" rows="15" onchange="documentDirty=true;" style="width:100%">'.$modx->htmlspecialchars($field_value).'</textarea>';
52 52
                 break;
53 53
             case "date":
54 54
                 $field_id = str_replace(array(
@@ -58,44 +58,44 @@  discard block
 block discarded – undo
58 58
                 if ($field_value == '') {
59 59
                     $field_value = 0;
60 60
                 }
61
-                $field_html .= '<input id="tv' . $field_id . '" name="tv' . $field_id . '" class="DatePicker" type="text" value="' . ($field_value == 0 || !isset($field_value) ? "" : $field_value) . '" onblur="documentDirty=true;" />';
62
-                $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].value=\'\';document.forms[\'mutate\'].elements[\'tv' . $field_id . '\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="' . $_style["actions_calendar_delete"] . '"></i></a>';
61
+                $field_html .= '<input id="tv'.$field_id.'" name="tv'.$field_id.'" class="DatePicker" type="text" value="'.($field_value == 0 || !isset($field_value) ? "" : $field_value).'" onblur="documentDirty=true;" />';
62
+                $field_html .= ' <a onclick="document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_id.'\'].onblur(); return true;" onmouseover="window.status=\'clear the date\'; return true;" onmouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><i class="'.$_style["actions_calendar_delete"].'"></i></a>';
63 63
 
64 64
                 break;
65 65
             case "dropdown": // handler for select boxes
66
-                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" size="1" onchange="documentDirty=true;">';
66
+                $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" size="1" onchange="documentDirty=true;">';
67 67
                 $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
68 68
                 while (list($item, $itemvalue) = each($index_list)) {
69 69
                     list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
70 70
                     if (strlen($itemvalue) == 0) {
71 71
                         $itemvalue = $item;
72 72
                     }
73
-                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
73
+                    $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
74 74
                 }
75 75
                 $field_html .= "</select>";
76 76
                 break;
77 77
             case "listbox": // handler for select boxes
78
-                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '" onchange="documentDirty=true;" size="8">';
78
+                $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'" onchange="documentDirty=true;" size="8">';
79 79
                 $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
80 80
                 while (list($item, $itemvalue) = each($index_list)) {
81 81
                     list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
82 82
                     if (strlen($itemvalue) == 0) {
83 83
                         $itemvalue = $item;
84 84
                     }
85
-                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . ($itemvalue == $field_value ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
85
+                    $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.($itemvalue == $field_value ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
86 86
                 }
87 87
                 $field_html .= "</select>";
88 88
                 break;
89 89
             case "listbox-multiple": // handler for select boxes where you can choose multiple items
90 90
                 $field_value = explode("||", $field_value);
91
-                $field_html .= '<select id="tv' . $field_id . '" name="tv' . $field_id . '[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
91
+                $field_html .= '<select id="tv'.$field_id.'" name="tv'.$field_id.'[]" multiple="multiple" onchange="documentDirty=true;" size="8">';
92 92
                 $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id, '', 'tvform', $tvsArray));
93 93
                 while (list($item, $itemvalue) = each($index_list)) {
94 94
                     list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue);
95 95
                     if (strlen($itemvalue) == 0) {
96 96
                         $itemvalue = $item;
97 97
                     }
98
-                    $field_html .= '<option value="' . $modx->htmlspecialchars($itemvalue) . '"' . (in_array($itemvalue, $field_value) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($item) . '</option>';
98
+                    $field_html .= '<option value="'.$modx->htmlspecialchars($itemvalue).'"'.(in_array($itemvalue, $field_value) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($item).'</option>';
99 99
                 }
100 100
                 $field_html .= "</select>";
101 101
                 break;
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
                     'ftp://' => 'ftp://',
108 108
                     'mailto:' => 'mailto:'
109 109
                 );
110
-                $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv' . $field_id . '_prefix" name="tv' . $field_id . '_prefix" onchange="documentDirty=true;">';
110
+                $field_html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_id.'_prefix" name="tv'.$field_id.'_prefix" onchange="documentDirty=true;">';
111 111
                 foreach ($urls as $k => $v) {
112 112
                     if (strpos($field_value, $v) === false) {
113
-                        $field_html .= '<option value="' . $v . '">' . $k . '</option>';
113
+                        $field_html .= '<option value="'.$v.'">'.$k.'</option>';
114 114
                     } else {
115 115
                         $field_value = str_replace($v, '', $field_value);
116
-                        $field_html .= '<option value="' . $v . '" selected="selected">' . $k . '</option>';
116
+                        $field_html .= '<option value="'.$v.'" selected="selected">'.$k.'</option>';
117 117
                     }
118 118
                 }
119 119
                 $field_html .= '</select></td><td>';
120
-                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" width="100" ' . $field_style . ' onchange="documentDirty=true;" /></td></tr></table>';
120
+                $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" width="100" '.$field_style.' onchange="documentDirty=true;" /></td></tr></table>';
121 121
                 break;
122 122
             case 'checkbox': // handles check boxes
123 123
                 $values = !is_array($field_value) ? explode('||', $field_value) : $field_value;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                     if (strlen($itemvalue) == 0) {
158 158
                         $itemvalue = $item;
159 159
                     }
160
-                    $field_html .= '<input type="radio" value="' . $modx->htmlspecialchars($itemvalue) . '" id="tv_' . $i . '" name="tv' . $field_id . '" ' . ($itemvalue == $field_value ? 'checked="checked"' : '') . ' onchange="documentDirty=true;" /><label for="tv_' . $i . '" class="radio">' . $item . '</label><br />';
160
+                    $field_html .= '<input type="radio" value="'.$modx->htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_id.'" '.($itemvalue == $field_value ? 'checked="checked"' : '').' onchange="documentDirty=true;" /><label for="tv_'.$i.'" class="radio">'.$item.'</label><br />';
161 161
                     $i++;
162 162
                 }
163 163
                 break;
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 									lastImageCtrl = ctrl;
188 188
 									var w = screen.width * 0.5;
189 189
 									var h = screen.height * 0.5;
190
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h);
190
+									OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h);
191 191
 								}
192 192
 								function BrowseFileServer(ctrl) {
193 193
 									lastFileCtrl = ctrl;
194 194
 									var w = screen.width * 0.5;
195 195
 									var h = screen.height * 0.5;
196
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h);
196
+									OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h);
197 197
 								}
198 198
 								function SetUrlChange(el) {
199 199
 									if ('createEvent' in document) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 						</script>";
228 228
                     $ResourceManagerLoaded = true;
229 229
                 }
230
-                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseServer(\'tv' . $field_id . '\')" />';
230
+                $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'"  value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseServer(\'tv'.$field_id.'\')" />';
231 231
                 break;
232 232
             case "file": // handles the input of file uploads
233 233
                 /* Modified by Timon for use with resource browser */
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
 									lastImageCtrl = ctrl;
258 258
 									var w = screen.width * 0.5;
259 259
 									var h = screen.height * 0.5;
260
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=images', w, h);
260
+									OpenServerBrowser('" . MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=images', w, h);
261 261
 								}
262 262
 								function BrowseFileServer(ctrl) {
263 263
 									lastFileCtrl = ctrl;
264 264
 									var w = screen.width * 0.5;
265 265
 									var h = screen.height * 0.5;
266
-									OpenServerBrowser('" . MODX_MANAGER_URL . "media/browser/{$which_browser}/browser.php?Type=files', w, h);
266
+									OpenServerBrowser('".MODX_MANAGER_URL."media/browser/{$which_browser}/browser.php?Type=files', w, h);
267 267
 								}
268 268
 								function SetUrlChange(el) {
269 269
 									if ('createEvent' in document) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 						</script>";
298 298
                     $ResourceManagerLoaded = true;
299 299
                 }
300
-                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '"  value="' . $field_value . '" ' . $field_style . ' onchange="documentDirty=true;" /><input type="button" value="' . $_lang['insert'] . '" onclick="BrowseFileServer(\'tv' . $field_id . '\')" />';
300
+                $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'"  value="'.$field_value.'" '.$field_style.' onchange="documentDirty=true;" /><input type="button" value="'.$_lang['insert'].'" onclick="BrowseFileServer(\'tv'.$field_id.'\')" />';
301 301
 
302 302
                 break;
303 303
 
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
                 $custom_output = '';
306 306
                 /* If we are loading a file */
307 307
                 if (substr($field_elements, 0, 5) == "@FILE") {
308
-                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 6));
308
+                    $file_name = MODX_BASE_PATH.trim(substr($field_elements, 6));
309 309
                     if (!file_exists($file_name)) {
310
-                        $custom_output = $file_name . ' does not exist';
310
+                        $custom_output = $file_name.' does not exist';
311 311
                     } else {
312 312
                         $custom_output = file_get_contents($file_name);
313 313
                     }
314 314
                 } elseif (substr($field_elements, 0, 8) == '@INCLUDE') {
315
-                    $file_name = MODX_BASE_PATH . trim(substr($field_elements, 9));
315
+                    $file_name = MODX_BASE_PATH.trim(substr($field_elements, 9));
316 316
                     if (!file_exists($file_name)) {
317
-                        $custom_output = $file_name . ' does not exist';
317
+                        $custom_output = $file_name.' does not exist';
318 318
                     } else {
319 319
                         ob_start();
320 320
                         include $file_name;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                     $chunk_name = trim(substr($field_elements, 7));
326 326
                     $chunk_body = $modx->getChunk($chunk_name);
327 327
                     if ($chunk_body == false) {
328
-                        $custom_output = $_lang['chunk_no_exist'] . '(' . $_lang['htmlsnippet_name'] . ':' . $chunk_name . ')';
328
+                        $custom_output = $_lang['chunk_no_exist'].'('.$_lang['htmlsnippet_name'].':'.$chunk_name.')';
329 329
                     } else {
330 330
                         $custom_output = $chunk_body;
331 331
                     }
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
                 break;
351 351
 
352 352
             default: // the default handler -- for errors, mostly
353
-                $field_html .= '<input type="text" id="tv' . $field_id . '" name="tv' . $field_id . '" value="' . $modx->htmlspecialchars($field_value) . '" ' . $field_style . ' onchange="documentDirty=true;" />';
353
+                $field_html .= '<input type="text" id="tv'.$field_id.'" name="tv'.$field_id.'" value="'.$modx->htmlspecialchars($field_value).'" '.$field_style.' onchange="documentDirty=true;" />';
354 354
 
355 355
         } // end switch statement
356 356
     } else {
357 357
         $custom = explode(":", $field_type);
358 358
         $custom_output = '';
359
-        $file_name = MODX_BASE_PATH . 'assets/tvs/' . $custom['1'] . '/' . $custom['1'] . '.customtv.php';
359
+        $file_name = MODX_BASE_PATH.'assets/tvs/'.$custom['1'].'/'.$custom['1'].'.customtv.php';
360 360
         if (!file_exists($file_name)) {
361
-            $custom_output = $file_name . ' does not exist';
361
+            $custom_output = $file_name.' does not exist';
362 362
         } else {
363 363
             ob_start();
364 364
             include $file_name;
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/browser.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -783,6 +783,9 @@  discard block
 block discarded – undo
783 783
         }
784 784
     }
785 785
 
786
+    /**
787
+     * @param string $dir
788
+     */
786 789
     protected function moveUploadFile($file, $dir)
787 790
     {
788 791
         $message = $this->checkUploadedFile($file);
@@ -817,6 +820,9 @@  discard block
 block discarded – undo
817 820
         return "/" . basename($target);
818 821
     }
819 822
 
823
+    /**
824
+     * @param string $file
825
+     */
820 826
     protected function sendDefaultThumb($file=null)
821 827
     {
822 828
         if ($file !== null) {
@@ -1028,6 +1034,9 @@  discard block
 block discarded – undo
1028 1034
         return "";
1029 1035
     }
1030 1036
 
1037
+    /**
1038
+     * @param string $message
1039
+     */
1031 1040
     protected function errorMsg($message, array $data=null)
1032 1041
     {
1033 1042
         if (in_array($this->action, array("thumb", "upload", "download", "downloadDir"))) {
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Browser actions class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Browser actions class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class browser extends uploader
16 16
 {
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             $this->get['dir'] = $dir;
39 39
         }
40 40
 
41
-        $thumbsDir = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'];
41
+        $thumbsDir = $this->config['uploadDir']."/".$this->config['thumbsDir'];
42 42
         if ((
43 43
                 !is_dir($thumbsDir) &&
44 44
                 !@mkdir($thumbsDir, $this->config['dirPerms'])
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $this->session['dir'] = $this->type;
109 109
         } else {
110 110
             $type = $this->getTypeFromPath($this->session['dir']);
111
-            $dir = $this->config['uploadDir'] . "/" . $this->session['dir'];
111
+            $dir = $this->config['uploadDir']."/".$this->session['dir'];
112 112
             if (($type != $this->type) || !is_dir($dir) || !is_readable($dir)) {
113 113
                 $this->session['dir'] = $this->type;
114 114
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         }
173 173
         $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/$file";
174 174
         if (!is_file($file) || !is_readable($file)) {
175
-            $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
175
+            $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/".basename($file);
176 176
             if (!is_file($file) || !is_readable($file)) {
177 177
                 $this->sendDefaultThumb($file);
178 178
             }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     protected function act_chDir()
206 206
     {
207 207
         $this->postDir(); // Just for existing check
208
-        $this->session['dir'] = $this->type . "/" . $this->post['dir'];
208
+        $this->session['dir'] = $this->type."/".$this->post['dir'];
209 209
         $dirWritable = dir::isWritable("{$this->config['uploadDir']}/{$this->session['dir']}");
210 210
         return json_encode(array(
211 211
             'files' => $this->getFiles($this->session['dir']),
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
         if (substr($newName, 0, 1) == ".") {
263 263
             $this->errorMsg("Folder name shouldn't begins with '.'");
264 264
         }
265
-        if (!@rename($dir, dirname($dir) . "/$newName")) {
265
+        if (!@rename($dir, dirname($dir)."/$newName")) {
266 266
             $this->errorMsg("Cannot rename the folder.");
267 267
         }
268 268
         $thumbDir = "$this->thumbsTypeDir/{$this->post['dir']}";
269 269
         if (is_dir($thumbDir)) {
270
-            @rename($thumbDir, dirname($thumbDir) . "/$newName");
270
+            @rename($thumbDir, dirname($thumbDir)."/$newName");
271 271
         }
272 272
         return json_encode(array('name' => $newName));
273 273
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         $dir = $this->postDir();
333 333
         if (!isset($this->post['dir']) ||
334 334
             !isset($this->post['file']) ||
335
-            strpos($this->post['file'], '../')!==false ||
335
+            strpos($this->post['file'], '../') !== false ||
336 336
             (false === ($file = "$dir/{$this->post['file']}")) ||
337 337
             !file_exists($file) || !is_readable($file)
338 338
         ) {
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
345 345
         header("Cache-Control: private", false);
346 346
         header("Content-Type: application/octet-stream");
347
-        header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $this->post['file']) . '"');
347
+        header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $this->post['file']).'"');
348 348
         header("Content-Transfer-Encoding:­ binary");
349
-        header("Content-Length: " . filesize($file));
349
+        header("Content-Length: ".filesize($file));
350 350
         readfile($file);
351 351
         die;
352 352
     }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
         if (!$this->config['access']['files']['rename'] ||
358 358
             !isset($this->post['dir']) ||
359 359
             !isset($this->post['file']) ||
360
-            strpos($this->post['file'], '../')!==false ||
360
+            strpos($this->post['file'], '../') !== false ||
361 361
             !isset($this->post['newName']) ||
362 362
             (false === ($file = "$dir/{$this->post['file']}")) ||
363 363
             !file_exists($file) || !is_readable($file) || !file::isWritable($file)
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
         $thumbFile = "$thumbDir/{$this->post['file']}";
401 401
 
402 402
         if (file_exists($thumbFile)) {
403
-            @rename($thumbFile, "$thumbDir/" . basename($newName));
403
+            @rename($thumbFile, "$thumbDir/".basename($newName));
404 404
         }
405 405
         return true;
406 406
     }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
         if (!$this->config['access']['files']['delete'] ||
412 412
             !isset($this->post['dir']) ||
413 413
             !isset($this->post['file']) ||
414
-            strpos($this->post['file'], '../')!==false ||
414
+            strpos($this->post['file'], '../') !== false ||
415 415
             (false === ($file = "$dir/{$this->post['file']}")) ||
416 416
             !file_exists($file) || !is_readable($file) || !file::isWritable($file) ||
417 417
             !@unlink($file)
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
             if (!file_exists($path)) {
457 457
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
458 458
             } elseif (substr($base, 0, 1) == ".") {
459
-                $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
459
+                $error[] = "$base: ".$this->label("File name shouldn't begins with '.'");
460 460
             } elseif (!$this->validateExtension($ext, $type)) {
461
-                $error[] = "$base: " . $this->label("Denied file extension.");
461
+                $error[] = "$base: ".$this->label("Denied file extension.");
462 462
             } elseif (file_exists("$dir/$base")) {
463
-                $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
463
+                $error[] = "$base: ".$this->label("A file or folder with that name already exists.");
464 464
             } elseif (!is_readable($path) || !is_file($path)) {
465 465
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
466 466
             } elseif (!@copy($path, "$dir/$base")) {
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
             if (!file_exists($path)) {
517 517
                 $error[] = $this->label("The file '{file}' does not exist.", $replace);
518 518
             } elseif (substr($base, 0, 1) == ".") {
519
-                $error[] = "$base: " . $this->label("File name shouldn't begins with '.'");
519
+                $error[] = "$base: ".$this->label("File name shouldn't begins with '.'");
520 520
             } elseif (!$this->validateExtension($ext, $type)) {
521
-                $error[] = "$base: " . $this->label("Denied file extension.");
521
+                $error[] = "$base: ".$this->label("Denied file extension.");
522 522
             } elseif (file_exists("$dir/$base")) {
523
-                $error[] = "$base: " . $this->label("A file or folder with that name already exists.");
523
+                $error[] = "$base: ".$this->label("A file or folder with that name already exists.");
524 524
             } elseif (!is_readable($path) || !is_file($path)) {
525 525
                 $error[] = $this->label("Cannot read '{file}'.", $replace);
526 526
             } elseif (!file::isWritable($path) || !@rename($path, "$dir/$base")) {
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
         if (!isset($this->post['dir']) || $this->config['denyZipDownload']) {
594 594
             $this->errorMsg("Unknown error.");
595 595
         }
596
-        $filename = basename($dir) . ".zip";
596
+        $filename = basename($dir).".zip";
597 597
         do {
598
-            $file = md5(time() . session_id());
598
+            $file = md5(time().session_id());
599 599
             $file = "{$this->config['uploadDir']}/$file.zip";
600 600
         } while (file_exists($file));
601 601
         new zipFolder($file, $dir);
602 602
         header("Content-Type: application/x-zip");
603
-        header('Content-Disposition: attachment; filename="' . str_replace('"', "_", $filename) . '"');
604
-        header("Content-Length: " . filesize($file));
603
+        header('Content-Disposition: attachment; filename="'.str_replace('"', "_", $filename).'"');
604
+        header("Content-Length: ".filesize($file));
605 605
         readfile($file);
606 606
         unlink($file);
607 607
         die;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
         }
633 633
 
634 634
         do {
635
-            $file = md5(time() . session_id());
635
+            $file = md5(time().session_id());
636 636
             $file = "{$this->config['uploadDir']}/$file.zip";
637 637
         } while (file_exists($file));
638 638
 
@@ -645,8 +645,8 @@  discard block
 block discarded – undo
645 645
             $zip->close();
646 646
         }
647 647
         header("Content-Type: application/x-zip");
648
-        header('Content-Disposition: attachment; filename="selected_files_' . basename($file) . '"');
649
-        header("Content-Length: " . filesize($file));
648
+        header('Content-Disposition: attachment; filename="selected_files_'.basename($file).'"');
649
+        header("Content-Length: ".filesize($file));
650 650
         readfile($file);
651 651
         unlink($file);
652 652
         die;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
             if ($type != $this->type) {
673 673
                 continue;
674 674
             }
675
-            $file = $this->config['uploadDir'] . "/$file";
675
+            $file = $this->config['uploadDir']."/$file";
676 676
             if (!is_file($file) || !is_readable($file)) {
677 677
                 continue;
678 678
             }
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
         }
681 681
 
682 682
         do {
683
-            $file = md5(time() . session_id());
683
+            $file = md5(time().session_id());
684 684
             $file = "{$this->config['uploadDir']}/$file.zip";
685 685
         } while (file_exists($file));
686 686
 
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
             $zip->close();
694 694
         }
695 695
         header("Content-Type: application/x-zip");
696
-        header('Content-Disposition: attachment; filename="clipboard_' . basename($file) . '"');
697
-        header("Content-Length: " . filesize($file));
696
+        header('Content-Disposition: attachment; filename="clipboard_'.basename($file).'"');
697
+        header("Content-Length: ".filesize($file));
698 698
         readfile($file);
699 699
         unlink($file);
700 700
         die;
@@ -746,23 +746,23 @@  discard block
 block discarded – undo
746 746
         } elseif (
747 747
             function_exists("curl_init") &&
748 748
             (false !== ($curl = @curl_init($url))) &&
749
-            (@ob_start()                 ||  (@curl_close($curl) && false)) &&
750
-            (@curl_exec($curl)           ||  (@curl_close($curl) && false)) &&
751
-            ((false !== ($ver = @ob_get_clean())) ||  (@curl_close($curl) && false)) &&
752
-            (@curl_close($curl)          ||  true) &&
749
+            (@ob_start() || (@curl_close($curl) && false)) &&
750
+            (@curl_exec($curl) || (@curl_close($curl) && false)) &&
751
+            ((false !== ($ver = @ob_get_clean())) || (@curl_close($curl) && false)) &&
752
+            (@curl_close($curl) || true) &&
753 753
             preg_match($pattern, $ver)
754 754
 
755 755
         // Socket extension
756 756
         ) {
757 757
         } elseif (function_exists('socket_create')) {
758 758
             $cmd =
759
-                "GET $path " . strtoupper($protocol) . "/1.1\r\n" .
760
-                "Host: $host\r\n" .
759
+                "GET $path ".strtoupper($protocol)."/1.1\r\n".
760
+                "Host: $host\r\n".
761 761
                 "Connection: Close\r\n\r\n";
762 762
 
763 763
             if ((false !== ($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) &&
764
-                (false !==    @socket_connect($socket, $host, $port)) &&
765
-                (false !==    @socket_write($socket, $cmd, strlen($cmd))) &&
764
+                (false !== @socket_connect($socket, $host, $port)) &&
765
+                (false !== @socket_write($socket, $cmd, strlen($cmd))) &&
766 766
                 (false !== ($ver = @socket_read($socket, 2048))) &&
767 767
                 preg_match($responsePattern, $ver, $match)
768 768
             ) {
@@ -795,14 +795,14 @@  discard block
 block discarded – undo
795 795
         }
796 796
 
797 797
         $filename = $this->normalizeFilename($file['name']);
798
-        $target = "$dir/" . file::getInexistantFilename($filename, $dir);
798
+        $target = "$dir/".file::getInexistantFilename($filename, $dir);
799 799
 
800 800
         if (!@move_uploaded_file($file['tmp_name'], $target) &&
801 801
             !@rename($file['tmp_name'], $target) &&
802 802
             !@copy($file['tmp_name'], $target)
803 803
         ) {
804 804
             @unlink($file['tmp_name']);
805
-            return "{$file['name']}: " . $this->label("Cannot move uploaded file to target folder.");
805
+            return "{$file['name']}: ".$this->label("Cannot move uploaded file to target folder.");
806 806
         } elseif (function_exists('chmod')) {
807 807
             chmod($target, $this->config['filePerms']);
808 808
         }
@@ -814,10 +814,10 @@  discard block
 block discarded – undo
814 814
 
815 815
         $this->makeThumb($target);
816 816
 
817
-        return "/" . basename($target);
817
+        return "/".basename($target);
818 818
     }
819 819
 
820
-    protected function sendDefaultThumb($file=null)
820
+    protected function sendDefaultThumb($file = null)
821 821
     {
822 822
         if ($file !== null) {
823 823
             $ext = file::getExtension($file);
@@ -844,10 +844,10 @@  discard block
 block discarded – undo
844 844
         foreach ($files as $file) {
845 845
             $ext = file::getExtension($file);
846 846
             $smallThumb = false;
847
-            if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg' ))) {
847
+            if (in_array(strtolower($ext), array('png', 'jpg', 'gif', 'jpeg'))) {
848 848
                 $size = @getimagesize($file);
849 849
                 if (is_array($size) && count($size)) {
850
-                    $thumb_file = "$thumbDir/" . basename($file);
850
+                    $thumb_file = "$thumbDir/".basename($file);
851 851
                     if (!is_file($thumb_file) || filemtime($file) > filemtime($thumb_file)) {
852 852
                         $this->makeThumb($file);
853 853
                     }
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             }
864 864
             $name = basename($file);
865 865
             $types = $this->config['types'];
866
-            $types = explode(' ', $types['images'] . ' ' . $types['image']);
866
+            $types = explode(' ', $types['images'].' '.$types['image']);
867 867
             if (substr($name, 0, 1) == '.' && !$this->config['showHiddenFiles']) {
868 868
                 continue;
869 869
             }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
         return $return;
890 890
     }
891 891
 
892
-    protected function getTree($dir, $index=0)
892
+    protected function getTree($dir, $index = 0)
893 893
     {
894 894
         $path = explode("/", $dir);
895 895
 
@@ -927,11 +927,11 @@  discard block
 block discarded – undo
927 927
         return $dirs;
928 928
     }
929 929
 
930
-    protected function postDir($existent=true)
930
+    protected function postDir($existent = true)
931 931
     {
932 932
         $dir = $this->typeDir;
933 933
         if (isset($this->post['dir'])) {
934
-            $dir .= "/" . $this->post['dir'];
934
+            $dir .= "/".$this->post['dir'];
935 935
         }
936 936
         if ($existent && (!is_dir($dir) || !is_readable($dir))) {
937 937
             $this->errorMsg("Inexistant or inaccessible folder.");
@@ -939,11 +939,11 @@  discard block
 block discarded – undo
939 939
         return $dir;
940 940
     }
941 941
 
942
-    protected function getDir($existent=true)
942
+    protected function getDir($existent = true)
943 943
     {
944 944
         $dir = $this->typeDir;
945 945
         if (isset($this->get['dir'])) {
946
-            $dir .= "/" . $this->get['dir'];
946
+            $dir .= "/".$this->get['dir'];
947 947
         }
948 948
         if ($existent && (!is_dir($dir) || !is_readable($dir))) {
949 949
             $this->errorMsg("Inexistant or inaccessible folder.");
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         return $return;
970 970
     }
971 971
 
972
-    protected function getDirInfo($dir, $removable=false)
972
+    protected function getDirInfo($dir, $removable = false)
973 973
     {
974 974
         if ((substr(basename($dir), 0, 1) == ".") || !is_dir($dir) || !is_readable($dir)) {
975 975
             return false;
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
         return $info;
1003 1003
     }
1004 1004
 
1005
-    protected function output($data=null, $template=null)
1005
+    protected function output($data = null, $template = null)
1006 1006
     {
1007 1007
         if (!is_array($data)) {
1008 1008
             $data = array();
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
         return "";
1029 1029
     }
1030 1030
 
1031
-    protected function errorMsg($message, array $data=null)
1031
+    protected function errorMsg($message, array $data = null)
1032 1032
     {
1033 1033
         if (in_array($this->action, array("thumb", "upload", "download", "downloadDir"))) {
1034 1034
             die($this->label($message, $data));
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -756,7 +756,7 @@
 block discarded – undo
756 756
         ) {
757 757
         } elseif (function_exists('socket_create')) {
758 758
             $cmd =
759
-                "GET $path " . strtoupper($protocol) . "/1.1\r\n" .
759
+                "get $path " . strtoupper($protocol) . "/1.1\r\n" .
760 760
                 "Host: $host\r\n" .
761 761
                 "Connection: Close\r\n\r\n";
762 762
 
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/core/uploader.php 3 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -427,6 +427,9 @@  discard block
 block discarded – undo
427 427
     }
428 428
 
429 429
 
430
+    /**
431
+     * @return string
432
+     */
430 433
     protected function normalizeFilename($filename)
431 434
     {
432 435
         if ($this->getTransaliasSettings()) {
@@ -437,6 +440,9 @@  discard block
 block discarded – undo
437 440
         return $filename;
438 441
     }
439 442
 
443
+    /**
444
+     * @param string $dirname
445
+     */
440 446
     protected function normalizeDirname($dirname)
441 447
     {
442 448
         return $this->modx->stripAlias($dirname);
@@ -566,6 +572,9 @@  discard block
 block discarded – undo
566 572
         return (is_dir($path) && is_readable($path)) ? $return : false;
567 573
     }
568 574
 
575
+    /**
576
+     * @param string $ext
577
+     */
569 578
     protected function validateExtension($ext, $type)
570 579
     {
571 580
         $ext = trim(strtolower($ext));
@@ -595,12 +604,18 @@  discard block
 block discarded – undo
595 604
         return in_array($ext, $exts);
596 605
     }
597 606
 
607
+    /**
608
+     * @return string
609
+     */
598 610
     protected function getTypeFromPath($path)
599 611
     {
600 612
         return preg_match('/^([^\/]*)\/.*$/', $path, $patt)
601 613
             ? $patt[1] : $path;
602 614
     }
603 615
 
616
+    /**
617
+     * @param string $path
618
+     */
604 619
     protected function removeTypeFromPath($path)
605 620
     {
606 621
         return preg_match('/^[^\/]*\/(.*)$/', $path, $patt)
@@ -811,6 +826,9 @@  discard block
 block discarded – undo
811 826
         die;
812 827
     }
813 828
 
829
+    /**
830
+     * @param string $url
831
+     */
814 832
     protected function callBack($url, $message="")
815 833
     {
816 834
         $message = text::jsValue($message);
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** This file is part of KCFinder project
4
-  *
5
-  *      @desc Uploader class
6
-  *   @package KCFinder
7
-  *   @version 2.54
8
-  *    @author Pavel Tzonkov <[email protected]>
9
-  * @copyright 2010-2014 KCFinder Project
10
-  *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
-  *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
-  *      @link http://kcfinder.sunhater.com
13
-  */
4
+ *
5
+ *      @desc Uploader class
6
+ *   @package KCFinder
7
+ *   @version 2.54
8
+ *    @author Pavel Tzonkov <[email protected]>
9
+ * @copyright 2010-2014 KCFinder Project
10
+ *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11
+ *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12
+ *      @link http://kcfinder.sunhater.com
13
+ */
14 14
 
15 15
 class uploader
16 16
 {
@@ -19,92 +19,92 @@  discard block
 block discarded – undo
19 19
     const VERSION = "2.54";
20 20
 
21 21
     /** Config session-overrided settings
22
-      * @var array */
22
+     * @var array */
23 23
     protected $config = array();
24 24
 
25 25
     /** Default image driver
26
-      * @var string */
26
+     * @var string */
27 27
     protected $imageDriver = "gd";
28 28
 
29 29
     /** Opener applocation properties
30
-      *   $opener['name']                 Got from $_GET['opener'];
31
-      *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
32
-      *   $opener['TinyMCE']              Boolean
33
-      * @var array */
30
+     *   $opener['name']                 Got from $_GET['opener'];
31
+     *   $opener['CKEditor']['funcNum']  CKEditor function number (got from $_GET)
32
+     *   $opener['TinyMCE']              Boolean
33
+     * @var array */
34 34
     protected $opener = array();
35 35
 
36 36
     /** Got from $_GET['type'] or first one $config['types'] array key, if inexistant
37
-      * @var string */
37
+     * @var string */
38 38
     protected $type;
39 39
 
40 40
     /** Helper property. Local filesystem path to the Type Directory
41
-      * Equivalent: $config['uploadDir'] . "/" . $type
42
-      * @var string */
41
+     * Equivalent: $config['uploadDir'] . "/" . $type
42
+     * @var string */
43 43
     protected $typeDir;
44 44
 
45 45
     /** Helper property. Web URL to the Type Directory
46
-      * Equivalent: $config['uploadURL'] . "/" . $type
47
-      * @var string */
46
+     * Equivalent: $config['uploadURL'] . "/" . $type
47
+     * @var string */
48 48
     protected $typeURL;
49 49
 
50 50
     /** Linked to $config['types']
51
-      * @var array */
51
+     * @var array */
52 52
     protected $types = array();
53 53
 
54 54
     /** Settings which can override default settings if exists as keys in $config['types'][$type] array
55
-      * @var array */
55
+     * @var array */
56 56
     protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts', 'watermark');
57 57
 
58 58
     /** Got from language file
59
-      * @var string */
59
+     * @var string */
60 60
     protected $charset;
61 61
 
62 62
     /** The language got from $_GET['lng'] or $_GET['lang'] or... Please see next property
63
-      * @var string */
63
+     * @var string */
64 64
     protected $lang = 'en';
65 65
 
66 66
     /** Possible language $_GET keys
67
-      * @var array */
67
+     * @var array */
68 68
     protected $langInputNames = array('lang', 'langCode', 'lng', 'language', 'lang_code');
69 69
 
70 70
     /** Uploaded file(s) info. Linked to first $_FILES element
71
-      * @var array */
71
+     * @var array */
72 72
     protected $file;
73 73
 
74 74
     /** Next three properties are got from the current language file
75
-      * @var string */
75
+     * @var string */
76 76
     protected $dateTimeFull;   // Currently not used
77 77
     protected $dateTimeMid;    // Currently not used
78 78
     protected $dateTimeSmall;
79 79
 
80 80
     /** Contain Specified language labels
81
-      * @var array */
81
+     * @var array */
82 82
     protected $labels = array();
83 83
 
84 84
     /** Contain unprocessed $_GET array. Please use this instead of $_GET
85
-      * @var array */
85
+     * @var array */
86 86
     protected $get;
87 87
 
88 88
     /** Contain unprocessed $_POST array. Please use this instead of $_POST
89
-      * @var array */
89
+     * @var array */
90 90
     protected $post;
91 91
 
92 92
     /** Contain unprocessed $_COOKIE array. Please use this instead of $_COOKIE
93
-      * @var array */
93
+     * @var array */
94 94
     protected $cookie;
95 95
 
96 96
     /** Session array. Please use this property instead of $_SESSION
97
-      * @var array */
97
+     * @var array */
98 98
     protected $session;
99 99
 
100 100
     /** CMS integration attribute (got from $_GET['cms'])
101
-      * @var string */
101
+     * @var string */
102 102
     protected $cms = "";
103 103
 
104 104
     protected $modx = null;
105 105
     /** Magic method which allows read-only access to protected or private class properties
106
-      * @param string $property
107
-      * @return mixed */
106
+     * @param string $property
107
+     * @return mixed */
108 108
     public function __get($property)
109 109
     {
110 110
         return property_exists($this, $property) ? $this->$property : null;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 
74 74
     /** Next three properties are got from the current language file
75 75
       * @var string */
76
-    protected $dateTimeFull;   // Currently not used
77
-    protected $dateTimeMid;    // Currently not used
76
+    protected $dateTimeFull; // Currently not used
77
+    protected $dateTimeMid; // Currently not used
78 78
     protected $dateTimeSmall;
79 79
 
80 80
     /** Contain Specified language labels
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
         // COOKIES INIT
229 229
         $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
230
-        $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/';
230
+        $ip = '/^'.implode('\.', array($ip, $ip, $ip, $ip)).'$/';
231 231
         if (preg_match($ip, $_SERVER['HTTP_HOST']) ||
232 232
             preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST'])
233 233
         ) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         ) {
248 248
             list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
249 249
             $path = path::normalize($path);
250
-            $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path";
250
+            $this->config['uploadURL'] = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/$path";
251 251
             $this->config['uploadDir'] = strlen($this->config['uploadDir'])
252 252
                 ? path::normalize($this->config['uploadDir'])
253 253
                 : path::url2fullPath("/$path");
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         foreach ($this->langInputNames as $key) {
294 294
             if (isset($this->get[$key]) &&
295 295
                 preg_match('/^[a-z][a-z\._\-]*$/i', $this->get[$key]) &&
296
-                file_exists("lang/" . strtolower($this->get[$key]) . ".php")
296
+                file_exists("lang/".strtolower($this->get[$key]).".php")
297 297
             ) {
298 298
                 $this->lang = $this->get[$key];
299 299
                 break;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                 }
365 365
 
366 366
                 $filename = $this->normalizeFilename($file['name']);
367
-                $target = file::getInexistantFilename($dir . $filename);
367
+                $target = file::getInexistantFilename($dir.$filename);
368 368
 
369 369
                 if (!@move_uploaded_file($file['tmp_name'], $target) &&
370 370
                     !@rename($file['tmp_name'], $target) &&
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
                     if (isset($udir)) {
381 381
                         $url .= "/$udir";
382 382
                     }
383
-                    $url .= "/" . basename($target);
383
+                    $url .= "/".basename($target);
384 384
                     if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)$/', $url, $patt)) {
385 385
                         list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
386
-                        $base = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/";
387
-                        $url = $base . path::urlPathEncode($path);
386
+                        $base = "$protocol://$domain".(strlen($port) ? ":$port" : "")."/";
387
+                        $url = $base.path::urlPathEncode($path);
388 388
                     } else {
389 389
                         $url = path::urlPathEncode($url);
390 390
                     }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 
413 413
         // Cleaning uploaded filename?
414 414
         $setting = $modx->db->select('count(*)', $modx->getFullTableName('system_settings'), 'setting_name="clean_uploaded_filename" AND setting_value=1');
415
-        if ($modx->db->getValue($setting)>0) {
415
+        if ($modx->db->getValue($setting) > 0) {
416 416
             // Transalias plugin active?
417 417
             $res = $modx->db->select('properties', $modx->getFullTableName('site_plugins'), 'name="TransAlias" AND disabled=0');
418 418
             if ($properties = $modx->db->getValue($res)) {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         if ($this->getTransaliasSettings()) {
433 433
             $format = strrchr($filename, ".");
434 434
             $filename = str_replace($format, "", $filename);
435
-            $filename = $this->modx->stripAlias($filename) . $format;
435
+            $filename = $this->modx->stripAlias($filename).$format;
436 436
         }
437 437
         return $filename;
438 438
     }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         return $this->modx->stripAlias($dirname);
443 443
     }
444 444
 
445
-    protected function checkUploadedFile(array $aFile=null)
445
+    protected function checkUploadedFile(array $aFile = null)
446 446
     {
447 447
         $config = &$this->config;
448 448
         $file = ($aFile === null) ? $this->file : $aFile;
@@ -484,8 +484,7 @@  discard block
 block discarded – undo
484 484
                 ($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ?
485 485
                     $this->label("Missing a temporary folder.") : (
486 486
                 ($file['error'] == UPLOAD_ERR_CANT_WRITE) ?
487
-                    $this->label("Failed to write file.") :
488
-                    $this->label("Unknown error.")
487
+                    $this->label("Failed to write file.") : $this->label("Unknown error.")
489 488
             )))));
490 489
         }
491 490
 
@@ -527,15 +526,15 @@  discard block
 block discarded – undo
527 526
 
528 527
 
529 528
         // CHECK FOR MODX MAX FILE SIZE
530
-        $actualfilesize=filesize($file['tmp_name']);
529
+        $actualfilesize = filesize($file['tmp_name']);
531 530
         if (isset($this->config['maxfilesize']) && $actualfilesize > $this->config['maxfilesize']) {
532
-            return $this->label("File is too big: " . $actualfilesize . " Bytes. (max " . $this->config['maxfilesize'] . " Bytes)");
531
+            return $this->label("File is too big: ".$actualfilesize." Bytes. (max ".$this->config['maxfilesize']." Bytes)");
533 532
         }
534 533
 
535 534
         return true;
536 535
     }
537 536
 
538
-    protected function checkInputDir($dir, $inclType=true, $existing=true)
537
+    protected function checkInputDir($dir, $inclType = true, $existing = true)
539 538
     {
540 539
         $dir = path::normalize($dir);
541 540
         if (substr($dir, 0, 1) == "/") {
@@ -607,7 +606,7 @@  discard block
 block discarded – undo
607 606
             ? $patt[1] : "";
608 607
     }
609 608
 
610
-    protected function imageResize($image, $file=null)
609
+    protected function imageResize($image, $file = null)
611 610
     {
612 611
         if (!($image instanceof image)) {
613 612
             $img = image::factory($this->imageDriver, $image);
@@ -702,7 +701,7 @@  discard block
 block discarded – undo
702 701
             $img->watermark($this->config['watermark']['file'], $left, $top);
703 702
         }
704 703
 
705
-        $options = array( 'file' => $file );
704
+        $options = array('file' => $file);
706 705
 
707 706
         $type = exif_imagetype($file);
708 707
 
@@ -714,11 +713,11 @@  discard block
 block discarded – undo
714 713
                 return $img->output('png', $options);
715 714
 
716 715
             default:
717
-                return $img->output('jpeg', array_merge($options, array( 'quality' => $this->config['jpegQuality'] )));
716
+                return $img->output('jpeg', array_merge($options, array('quality' => $this->config['jpegQuality'])));
718 717
         }
719 718
     }
720 719
 
721
-    protected function makeThumb($file, $overwrite=true)
720
+    protected function makeThumb($file, $overwrite = true)
722 721
     {
723 722
         $img = image::factory($this->imageDriver, $file);
724 723
 
@@ -728,7 +727,7 @@  discard block
 block discarded – undo
728 727
         }
729 728
 
730 729
         $thumb = substr($file, strlen($this->config['uploadDir']));
731
-        $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
730
+        $thumb = $this->config['uploadDir']."/".$this->config['thumbsDir']."/".$thumb;
732 731
         $thumb = path::normalize($thumb);
733 732
         $thumbDir = dirname($thumb);
734 733
         if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
@@ -757,8 +756,8 @@  discard block
 block discarded – undo
757 756
         if ($this->imageDriver == 'gd') {
758 757
             $width  = imagesx($img->image);
759 758
             $height = imagesy($img->image);
760
-            $back   = image::factory($this->imageDriver, array( $width, $height ));
761
-            $tile   = image::factory($this->imageDriver, __DIR__ . '/../themes/' . $this->config['theme'] . '/img/bg_transparent.png');
759
+            $back   = image::factory($this->imageDriver, array($width, $height));
760
+            $tile   = image::factory($this->imageDriver, __DIR__.'/../themes/'.$this->config['theme'].'/img/bg_transparent.png');
762 761
 
763 762
             imagesettile($back->image, $tile->image);
764 763
             imagefilledrectangle($back->image, 0, 0, $width, $height, IMG_COLOR_TILED);
@@ -790,7 +789,7 @@  discard block
 block discarded – undo
790 789
         $this->labels = $lang;
791 790
     }
792 791
 
793
-    protected function label($string, array $data=null)
792
+    protected function label($string, array $data = null)
794 793
     {
795 794
         $return = isset($this->labels[$string]) ? $this->labels[$string] : $string;
796 795
         if (is_array($data)) {
@@ -801,7 +800,7 @@  discard block
 block discarded – undo
801 800
         return $return;
802 801
     }
803 802
 
804
-    protected function backMsg($message, array $data=null)
803
+    protected function backMsg($message, array $data = null)
805 804
     {
806 805
         $message = $this->label($message, $data);
807 806
         if (isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
@@ -811,7 +810,7 @@  discard block
 block discarded – undo
811 810
         die;
812 811
     }
813 812
 
814
-    protected function callBack($url, $message="")
813
+    protected function callBack($url, $message = "")
815 814
     {
816 815
         $message = text::jsValue($message);
817 816
         $CKfuncNum = isset($this->opener['CKEditor']['funcNum'])
Please login to merge, or discard this patch.
manager/media/browser/mcpuk/lib/class_fastImage.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -177,6 +177,9 @@  discard block
 block discarded – undo
177 177
     }
178 178
 
179 179
 
180
+    /**
181
+     * @param integer $n
182
+     */
180 183
     private function getChars($n)
181 184
     {
182 185
         $response = null;
@@ -214,6 +217,9 @@  discard block
 block discarded – undo
214 217
     }
215 218
 
216 219
 
220
+    /**
221
+     * @param false|string $str
222
+     */
217 223
     private function readInt($str)
218 224
     {
219 225
         $size = unpack("C*", $str);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
                     return $this->type = 'bmp';
68 68
                 case "GI":
69 69
                     return $this->type = 'gif';
70
-                case chr(0xFF) . chr(0xd8):
70
+                case chr(0xFF).chr(0xd8):
71 71
                     return $this->type = 'jpeg';
72
-                case chr(0x89) . 'P':
72
+                case chr(0x89).'P':
73 73
                     return $this->type = 'png';
74 74
                 default:
75 75
                     return false;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $response = null;
183 183
 
184 184
         // do we need more data?
185
-        if ($this->strpos + $n -1 >= strlen($this->str)) {
185
+        if ($this->strpos + $n - 1 >= strlen($this->str)) {
186 186
             $end = ($this->strpos + $n);
187 187
 
188 188
             while (strlen($this->str) < $end && $response !== false) {
Please login to merge, or discard this patch.