Completed
Push — 2.x ( 68042a...a2016b )
by Naoki
03:03
created
php/elFinderVolumeLocalFileSystem.class.php 2 patches
Doc Comments   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 * Return true if path is dir and has at least one childs directory
543 543
 	 *
544 544
 	 * @param  string  $path  dir path
545
-	 * @return bool
545
+	 * @return null|false
546 546
 	 * @author Dmitry (dio) Levashov
547 547
 	 **/
548 548
 	protected function _subdirs($path) {
@@ -696,7 +696,6 @@  discard block
 block discarded – undo
696 696
 	 * Open file and return file pointer
697 697
 	 *
698 698
 	 * @param  string  $path  file path
699
-	 * @param  bool    $write open file for writing
700 699
 	 * @return resource|false
701 700
 	 * @author Dmitry (dio) Levashov
702 701
 	 **/
@@ -722,7 +721,7 @@  discard block
 block discarded – undo
722 721
 	 *
723 722
 	 * @param  string  $path  parent dir path
724 723
 	 * @param string  $name  new directory name
725
-	 * @return string|bool
724
+	 * @return string|false
726 725
 	 * @author Dmitry (dio) Levashov
727 726
 	 **/
728 727
 	protected function _mkdir($path, $name) {
@@ -742,7 +741,7 @@  discard block
 block discarded – undo
742 741
 	 *
743 742
 	 * @param  string  $path  parent dir path
744 743
 	 * @param string  $name  new file name
745
-	 * @return string|bool
744
+	 * @return string|false
746 745
 	 * @author Dmitry (dio) Levashov
747 746
 	 **/
748 747
 	protected function _mkfile($path, $name) {
@@ -790,9 +789,9 @@  discard block
 block discarded – undo
790 789
 	 * Return new file path or false.
791 790
 	 *
792 791
 	 * @param  string  $source  source file path
793
-	 * @param  string  $target  target dir path
792
+	 * @param  string  $targetDir  target dir path
794 793
 	 * @param  string  $name    file name
795
-	 * @return string|bool
794
+	 * @return string|false
796 795
 	 * @author Dmitry (dio) Levashov
797 796
 	 **/
798 797
 	protected function _move($source, $targetDir, $name) {
@@ -836,7 +835,7 @@  discard block
 block discarded – undo
836 835
 	 * @param  string    $dir  target dir path
837 836
 	 * @param  string    $name file name
838 837
 	 * @param  array     $stat file stat (required by some virtual fs)
839
-	 * @return bool|string
838
+	 * @return false|string
840 839
 	 * @author Dmitry (dio) Levashov
841 840
 	 **/
842 841
 	protected function _save($fp, $dir, $name, $stat) {
@@ -868,7 +867,7 @@  discard block
 block discarded – undo
868 867
 	 * Get file contents
869 868
 	 *
870 869
 	 * @param  string  $path  file path
871
-	 * @return string|false
870
+	 * @return string
872 871
 	 * @author Dmitry (dio) Levashov
873 872
 	 **/
874 873
 	protected function _getContents($path) {
@@ -1072,7 +1071,7 @@  discard block
 block discarded – undo
1072 1071
 	 * @param  array   $files  files names list
1073 1072
 	 * @param  string  $name   archive name
1074 1073
 	 * @param  array   $arc    archiver options
1075
-	 * @return string|bool
1074
+	 * @return string|false
1076 1075
 	 * @author Dmitry (dio) Levashov, 
1077 1076
 	 * @author Alexey Sukhotin
1078 1077
 	 **/
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Implement similar functionality in PHP 5.2 or 5.3
4 4
 // http://php.net/manual/class.recursivecallbackfilteriterator.php#110974
5
-if (! class_exists('RecursiveCallbackFilterIterator', false)) {
5
+if (!class_exists('RecursiveCallbackFilterIterator', false)) {
6 6
 	class RecursiveCallbackFilterIterator extends RecursiveFilterIterator {
7 7
 	   
8
-	    public function __construct ( RecursiveIterator $iterator, $callback ) {
8
+	    public function __construct(RecursiveIterator $iterator, $callback) {
9 9
 	        $this->callback = $callback;
10 10
 	        parent::__construct($iterator);
11 11
 	    }
12 12
 	   
13
-	    public function accept () {
13
+	    public function accept() {
14 14
 	        $callback = $this->callback;
15 15
 	        return $callback(parent::current(), parent::key(), parent::getInnerIterator());
16 16
 	    }
17 17
 	   
18
-	    public function getChildren () {
18
+	    public function getChildren() {
19 19
 	        return new self($this->getInnerIterator()->getChildren(), $this->callback);
20 20
 	    }
21 21
 	}
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @author Dmitry (dio) Levashov
61 61
 	 **/
62 62
 	public function __construct() {
63
-		$this->options['alias']    = '';              // alias to replace root dir name
64
-		$this->options['dirMode']  = 0755;            // new dirs mode
65
-		$this->options['fileMode'] = 0644;            // new files mode
66
-		$this->options['quarantine'] = '.quarantine';  // quarantine folder name - required to check archive (must be hidden)
67
-		$this->options['maxArcFilesSize'] = 0;        // max allowed archive files size (0 - no limit)
63
+		$this->options['alias']    = ''; // alias to replace root dir name
64
+		$this->options['dirMode']  = 0755; // new dirs mode
65
+		$this->options['fileMode'] = 0644; // new files mode
66
+		$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
67
+		$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
68 68
 		$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
69 69
 	}
70 70
 	
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	protected function init() {
82 82
 		// Normalize directory separator for windows
83 83
 		if (DIRECTORY_SEPARATOR !== '/') {
84
-			foreach(array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
84
+			foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
85 85
 				if (!empty($this->options[$key])) {
86 86
 					$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
87 87
 				}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		// if no thumbnails url - try detect it
146 146
 		if ($root['read'] && !$this->tmbURL && $this->URL) {
147 147
 			if (strpos($this->tmbPath, $this->root) === 0) {
148
-				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
148
+				$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
149 149
 				if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
150 150
 					$this->tmbURL .= '/';
151 151
 				}
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		if ($mtime != $compare) {
204 204
 			return $mtime;
205 205
 		}
206
-		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH')? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
206
+		$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
207 207
 		$path = escapeshellarg($path);
208 208
 		$standby = max(1, intval($standby));
209 209
 		$cmd = $inotifywait.' '.$path.' -t '.$standby.' -e moved_to,moved_from,move,create,delete,delete_self';
210
-		$this->procExec($cmd , $o, $r);
210
+		$this->procExec($cmd, $o, $r);
211 211
 		if ($r === 0) {
212 212
 			// changed
213 213
 			clearstatcache();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		}
219 219
 		// error
220 220
 		// cache to $_SESSION
221
-		$sessionClose = true;;
221
+		$sessionClose = true; ;
222 222
 		try {
223 223
 			$sessionStart = session_start();
224 224
 		} catch (Exception $e) {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @author Dmitry (dio) Levashov
271 271
 	 **/
272 272
 	protected function _joinPath($dir, $name) {
273
-		return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
273
+		return rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$name;
274 274
 	}
275 275
 	
276 276
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		$comps = $new_comps;
323 323
 		$path = implode('/', $comps);
324 324
 		if ($initial_slashes) {
325
-			$path = str_repeat('/', $initial_slashes) . $path;
325
+			$path = str_repeat('/', $initial_slashes).$path;
326 326
 		}
327 327
 		
328 328
 		if ($changeSep) {
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 **/
394 394
 	protected function _inpath($path, $parent) {
395 395
 		$cwd = getcwd();
396
-		$real_path   = $this->getFullPath($path,   $cwd);
396
+		$real_path   = $this->getFullPath($path, $cwd);
397 397
 		$real_parent = $this->getFullPath($parent, $cwd);
398 398
 		if ($real_path && $real_parent) {
399 399
 			return $real_path === $real_parent || strpos($real_path, rtrim($real_parent, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR) === 0;
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 					$stat = array();
453 453
 					return $stat;
454 454
 				} else {
455
-					$stat['mime']  = 'symlink-broken';
455
+					$stat['mime'] = 'symlink-broken';
456 456
 					$target = readlink($path);
457 457
 					$lstat = lstat($path);
458 458
 					$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 			$fstat = stat($path);
469 469
 			$uid = $fstat['uid'];
470 470
 			$gid = $fstat['gid'];
471
-			$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
471
+			$stat['perm'] = substr((string) decoct($fstat['mode']), -4);
472 472
 			$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
473 473
 		}
474 474
 		
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 			$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
479 479
 		}
480 480
 		//logical rights first
481
-		$stat['read'] = ($linkreadable || is_readable($path))? null : false;
482
-		$stat['write'] = is_writable($path)? null : false;
481
+		$stat['read'] = ($linkreadable || is_readable($path)) ? null : false;
482
+		$stat['write'] = is_writable($path) ? null : false;
483 483
 
484 484
 		if (is_null($stat['read'])) {
485 485
 			$stat['size'] = $dir ? 0 : $size;
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			$dirItr = new ParentIterator(
552 552
 				new RecursiveDirectoryIterator($path,
553 553
 					FilesystemIterator::SKIP_DOTS |
554
-					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')?
554
+					(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ?
555 555
 						RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0)
556 556
 				)
557 557
 			);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 							$br = true;
638 638
 						} else {
639 639
 							$_path = $fpath;
640
-							$stat['mime']  = 'symlink-broken';
640
+							$stat['mime'] = 'symlink-broken';
641 641
 							$target = readlink($_path);
642 642
 							$lstat = lstat($_path);
643 643
 							$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 					if ($statOwner && !$linkreadable) {
663 663
 						$uid = $file->getOwner();
664 664
 						$gid = $file->getGroup();
665
-						$stat['perm'] = substr((string)decoct($file->getPerms()), -4);
665
+						$stat['perm'] = substr((string) decoct($file->getPerms()), -4);
666 666
 						$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
667 667
 					}
668 668
 					
669 669
 					//logical rights first
670
-					$stat['read'] = ($linkreadable || $file->isReadable())? null : false;
671
-					$stat['write'] = $file->isWritable()? null : false;
670
+					$stat['read'] = ($linkreadable || $file->isReadable()) ? null : false;
671
+					$stat['write'] = $file->isWritable() ? null : false;
672 672
 					
673 673
 					if (is_null($stat['read'])) {
674 674
 						$stat['size'] = $dir ? 0 : $size;
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 		
685 685
 		if ($cache) {
686 686
 			$cache = $this->convEncOut($cache, false);
687
-			foreach($cache as $d) {
687
+			foreach ($cache as $d) {
688 688
 				$this->updateCache($d[0], $d[1]);
689 689
 			}
690 690
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	 * @return resource|false
701 701
 	 * @author Dmitry (dio) Levashov
702 702
 	 **/
703
-	protected function _fopen($path, $mode='rb') {
703
+	protected function _fopen($path, $mode = 'rb') {
704 704
 		return @fopen($path, $mode);
705 705
 	}
706 706
 	
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 * @return bool
712 712
 	 * @author Dmitry (dio) Levashov
713 713
 	 **/
714
-	protected function _fclose($fp, $path='') {
714
+	protected function _fclose($fp, $path = '') {
715 715
 		return @fclose($fp);
716 716
 	}
717 717
 	
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 		$path = $this->_joinPath($dir, $name);
844 844
 
845 845
 		$meta = stream_get_meta_data($fp);
846
-		$uri = isset($meta['uri'])? $meta['uri'] : '';
846
+		$uri = isset($meta['uri']) ? $meta['uri'] : '';
847 847
 		if ($uri && @is_file($uri)) {
848 848
 			fclose($fp);
849 849
 			$isCmdPaste = ($this->ARGS['cmd'] === 'paste');
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 	 * @return bool
908 908
 	 **/
909 909
 	protected function _chmod($path, $mode) {
910
-		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
910
+		$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o", $mode));
911 911
 		$ret = @chmod($path, $modeOct);
912 912
 		$ret && clearstatcache();
913 913
 		return  $ret;
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 				$src = $dir;
1026 1026
 				$name = basename($path);
1027 1027
 				if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
1028
-					$name = substr($name, 0,  strlen($name)-strlen($m[0]));
1028
+					$name = substr($name, 0, strlen($name) - strlen($m[0]));
1029 1029
 				}
1030 1030
 				$test = dirname($path).DIRECTORY_SEPARATOR.$name;
1031 1031
 				if (file_exists($test) || is_link($test)) {
@@ -1034,9 +1034,9 @@  discard block
 block discarded – undo
1034 1034
 			}
1035 1035
 			
1036 1036
 			if ($name !== '') {
1037
-				$result  = dirname($path).DIRECTORY_SEPARATOR.$name;
1037
+				$result = dirname($path).DIRECTORY_SEPARATOR.$name;
1038 1038
 
1039
-				if (! @rename($src, $result)) {
1039
+				if (!@rename($src, $result)) {
1040 1040
 					$this->delTree($dir);
1041 1041
 					return false;
1042 1042
 				}
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 				$dstDir = dirname($path);
1045 1045
 				$res = false;
1046 1046
 				$result = array();
1047
-				foreach($ls as $name) {
1047
+				foreach ($ls as $name) {
1048 1048
 					$target = $dstDir.DIRECTORY_SEPARATOR.$name;
1049 1049
 					if (is_dir($target)) {
1050 1050
 						$this->delTree($target);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 					new RecursiveDirectoryIterator($path,
1131 1131
 						FilesystemIterator::KEY_AS_PATHNAME |
1132 1132
 						FilesystemIterator::SKIP_DOTS |
1133
-						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')?
1133
+						(defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ?
1134 1134
 							RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0)
1135 1135
 					),
1136 1136
 					array($this, 'localFileSystemSearchIteratorFilter')
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 		$result = array();
1153 1153
 		
1154 1154
 		if ($match) {
1155
-			foreach($match as $p) {
1155
+			foreach ($match as $p) {
1156 1156
 				$stat = $this->stat($p);
1157 1157
 		
1158 1158
 				if (!$stat) { // invalid links
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 					$stat['path'] = $this->path($stat['hash']);
1170 1170
 					if ($this->URL && !isset($stat['url'])) {
1171 1171
 						$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
1172
-						$stat['url'] = $this->URL . $path;
1172
+						$stat['url'] = $this->URL.$path;
1173 1173
 					}
1174 1174
 		
1175 1175
 					$result[] = $stat;
@@ -1184,9 +1184,9 @@  discard block
 block discarded – undo
1184 1184
 
1185 1185
 	public function localFileSystemSearchIteratorFilter($file, $key, $iterator) {
1186 1186
 		if ($iterator->hasChildren()) {
1187
-			return (bool)$this->attr($key, 'read', null, true);
1187
+			return (bool) $this->attr($key, 'read', null, true);
1188 1188
 		}
1189
-		return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true;
1189
+		return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false) ? false : true;
1190 1190
 	}
1191 1191
 	
1192 1192
 } // END class 
Please login to merge, or discard this patch.