@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** {Indonesian} localization file for KCFinder |
4 | - * -Razi Senseio (Author) |
|
5 | - */ |
|
4 | + * -Razi Senseio (Author) |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 | |
9 | - '_locale' => "id_ID.UTF-8", // UNIX localization code |
|
10 | - '_charset' => "utf-8", // Browser charset |
|
9 | + '_locale' => "id_ID.UTF-8", // UNIX localization code |
|
10 | + '_charset' => "utf-8", // Browser charset |
|
11 | 11 | |
12 | 12 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
13 | 13 | '_dateTimeFull' => "%A, %e %B, %Y %H:%M", |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** Dutch localization file for KCFinder |
4 | - * author: Lars Anderson <[email protected]> |
|
5 | - */ |
|
4 | + * author: Lars Anderson <[email protected]> |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 | |
9 | - '_locale' => "nl_NL.UTF-8", // UNIX localization code |
|
10 | - '_charset' => "utf-8", // Browser charset |
|
9 | + '_locale' => "nl_NL.UTF-8", // UNIX localization code |
|
10 | + '_charset' => "utf-8", // Browser charset |
|
11 | 11 | |
12 | 12 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
13 | 13 | '_dateTimeFull' => "%A, %e.%B.%Y %H:%M", |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** vi localization file for KCFinder |
4 | - * Tran Van Quyet - HQV ltd |
|
5 | - */ |
|
4 | + * Tran Van Quyet - HQV ltd |
|
5 | + */ |
|
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | $lang = array( |
8 | 8 | |
9 | - '_locale' => "vi_VN.UTF-8", // UNIX localization code |
|
10 | - '_charset' => "utf-8", // Browser charset |
|
9 | + '_locale' => "vi_VN.UTF-8", // UNIX localization code |
|
10 | + '_charset' => "utf-8", // Browser charset |
|
11 | 11 | |
12 | 12 | // Date time formats. See http://www.php.net/manual/en/function.strftime.php |
13 | 13 | '_dateTimeFull' => "%A, %e %B, %Y %H:%M", |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Base CSS definitions |
|
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 Base CSS definitions |
|
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 | require "core/autoload.php"; |
16 | 16 | $mtime = @filemtime(__FILE__); |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | require "core/autoload.php"; |
16 | 16 | $mtime = @filemtime(__FILE__); |
17 | -if ($mtime) httpCache::checkMTime($mtime); |
|
17 | +if ($mtime) { |
|
18 | + httpCache::checkMTime($mtime); |
|
19 | +} |
|
18 | 20 | $browser = new browser($modx); |
19 | 21 | $config = $browser->config; |
20 | 22 | ob_start(); |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Load language labels into JavaScript |
|
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 Load language labels into JavaScript |
|
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 | require "core/autoload.php"; |
16 | 16 | $input = new input(); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | header("Content-Type: text/javascript"); |
19 | 19 | die; |
20 | 20 | } |
21 | -$file = "lang/" . $input->get['lng'] . ".php"; |
|
21 | +$file = "lang/".$input->get['lng'].".php"; |
|
22 | 22 | $files = dir::content("lang", array( |
23 | 23 | 'types' => "file", |
24 | 24 | 'pattern' => '/^.*\.php$/' |
@@ -33,4 +33,4 @@ discard block |
||
33 | 33 | header("Content-Type: text/javascript; charset={$lang['_charset']}"); |
34 | 34 | foreach ($lang as $english => $native) |
35 | 35 | if (substr($english, 0, 1) != "_") |
36 | - echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";"; |
|
36 | + echo "browser.labels['".text::jsValue($english)."']=\"".text::jsValue($native)."\";"; |
@@ -28,9 +28,12 @@ |
||
28 | 28 | die; |
29 | 29 | } |
30 | 30 | $mtime = @filemtime($file); |
31 | -if ($mtime) httpCache::checkMTime($mtime); |
|
31 | +if ($mtime) { |
|
32 | + httpCache::checkMTime($mtime); |
|
33 | +} |
|
32 | 34 | require $file; |
33 | 35 | header("Content-Type: text/javascript; charset={$lang['_charset']}"); |
34 | -foreach ($lang as $english => $native) |
|
36 | +foreach ($lang as $english => $native) { |
|
35 | 37 | if (substr($english, 0, 1) != "_") |
36 | 38 | echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";"; |
39 | +} |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Join all JavaScript files in current directory |
|
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 Join all JavaScript files in current directory |
|
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 | chdir(".."); // For compatibility |
16 | 16 | chdir(".."); |
@@ -23,11 +23,13 @@ |
||
23 | 23 | |
24 | 24 | foreach ($files as $file) { |
25 | 25 | $fmtime = filemtime($file); |
26 | - if (!isset($mtime) || ($fmtime > $mtime)) |
|
27 | - $mtime = $fmtime; |
|
28 | -} |
|
26 | + if (!isset($mtime) || ($fmtime > $mtime)) { |
|
27 | + $mtime = $fmtime; |
|
28 | + } |
|
29 | + } |
|
29 | 30 | |
30 | 31 | httpCache::checkMTime($mtime); |
31 | 32 | header("Content-Type: text/javascript"); |
32 | -foreach ($files as $file) |
|
33 | +foreach ($files as $file) { |
|
33 | 34 | require $file; |
35 | +} |
@@ -10,14 +10,14 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
13 | + if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | + elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | 15 | else $type = 'images'; |
16 | 16 | |
17 | 17 | if($type==='image') $type = 'images'; |
18 | 18 | |
19 | - $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | - $request_uri = "{$opener}&type={$type}"; |
|
19 | + $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | + $request_uri = "{$opener}&type={$type}"; |
|
21 | 21 | ?> |
22 | 22 | window.location.href = "browse.php?<?php echo $request_uri; ?>"; |
23 | 23 | </script> |
@@ -10,13 +10,13 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
13 | + if (isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | + elseif (isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | 15 | else $type = 'images'; |
16 | 16 | |
17 | - if($type==='image') $type = 'images'; |
|
17 | + if ($type === 'image') $type = 'images'; |
|
18 | 18 | |
19 | - $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
19 | + $opener = (isset($_GET['editor'])) ? 'opener='.htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | 20 | $request_uri = "{$opener}&type={$type}"; |
21 | 21 | ?> |
22 | 22 | window.location.href = "browse.php?<?php echo $request_uri; ?>"; |
@@ -10,11 +10,17 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | - else $type = 'images'; |
|
13 | + if(isset($_GET['type'])) { |
|
14 | + $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
15 | + } elseif(isset($_GET['Type'])) { |
|
16 | + $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
17 | + } else { |
|
18 | + $type = 'images'; |
|
19 | + } |
|
16 | 20 | |
17 | - if($type==='image') $type = 'images'; |
|
21 | + if($type==='image') { |
|
22 | + $type = 'images'; |
|
23 | + } |
|
18 | 24 | |
19 | 25 | $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
20 | 26 | $request_uri = "{$opener}&type={$type}"; |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Directory helper 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 Directory helper 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 dir { |
16 | 16 | |
17 | - /** Checks if the given directory is really writable. The standard PHP |
|
18 | - * function is_writable() does not work properly on Windows servers |
|
19 | - * @param string $dir |
|
20 | - * @return bool */ |
|
17 | + /** Checks if the given directory is really writable. The standard PHP |
|
18 | + * function is_writable() does not work properly on Windows servers |
|
19 | + * @param string $dir |
|
20 | + * @return bool */ |
|
21 | 21 | |
22 | 22 | static function isWritable($dir) { |
23 | 23 | $dir = path::normalize($dir); |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
36 | - /** Recursively delete the given directory. Returns TRUE on success. |
|
37 | - * If $firstFailExit parameter is true (default), the method returns the |
|
38 | - * path to the first failed file or directory which cannot be deleted. |
|
39 | - * If $firstFailExit is false, the method returns an array with failed |
|
40 | - * files and directories which cannot be deleted. The third parameter |
|
41 | - * $failed is used for internal use only. |
|
42 | - * @param string $dir |
|
43 | - * @param bool $firstFailExit |
|
44 | - * @param array $failed |
|
45 | - * @return mixed */ |
|
36 | + /** Recursively delete the given directory. Returns TRUE on success. |
|
37 | + * If $firstFailExit parameter is true (default), the method returns the |
|
38 | + * path to the first failed file or directory which cannot be deleted. |
|
39 | + * If $firstFailExit is false, the method returns an array with failed |
|
40 | + * files and directories which cannot be deleted. The third parameter |
|
41 | + * $failed is used for internal use only. |
|
42 | + * @param string $dir |
|
43 | + * @param bool $firstFailExit |
|
44 | + * @param array $failed |
|
45 | + * @return mixed */ |
|
46 | 46 | |
47 | 47 | static function prune($dir, $firstFailExit=true, array $failed=null) { |
48 | 48 | if ($failed === null) $failed = array(); |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | return count($failed) ? $failed : true; |
82 | 82 | } |
83 | 83 | |
84 | - /** Get the content of the given directory. Returns an array with filenames |
|
85 | - * or FALSE on failure |
|
86 | - * @param string $dir |
|
87 | - * @param array $options |
|
88 | - * @return mixed */ |
|
84 | + /** Get the content of the given directory. Returns an array with filenames |
|
85 | + * or FALSE on failure |
|
86 | + * @param string $dir |
|
87 | + * @param array $options |
|
88 | + * @return mixed */ |
|
89 | 89 | |
90 | 90 | static function content($dir, array $options=null) { |
91 | 91 |
@@ -12,20 +12,20 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class dir { |
|
15 | +class dir{ |
|
16 | 16 | |
17 | 17 | /** Checks if the given directory is really writable. The standard PHP |
18 | 18 | * function is_writable() does not work properly on Windows servers |
19 | 19 | * @param string $dir |
20 | 20 | * @return bool */ |
21 | 21 | |
22 | - static function isWritable($dir) { |
|
22 | + static function isWritable($dir){ |
|
23 | 23 | $dir = path::normalize($dir); |
24 | 24 | if (!is_dir($dir)) |
25 | 25 | return false; |
26 | 26 | $i = 0; |
27 | 27 | do { |
28 | - $file = "$dir/is_writable_" . md5($i++); |
|
28 | + $file = "$dir/is_writable_".md5($i++); |
|
29 | 29 | } while (file_exists($file)); |
30 | 30 | if (!@touch($file)) |
31 | 31 | return false; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $failed |
45 | 45 | * @return mixed */ |
46 | 46 | |
47 | - static function prune($dir, $firstFailExit=true, array $failed=null) { |
|
47 | + static function prune($dir, $firstFailExit = true, array $failed = null){ |
|
48 | 48 | if ($failed === null) $failed = array(); |
49 | 49 | $files = self::content($dir); |
50 | 50 | if ($files === false) { |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * @param array $options |
88 | 88 | * @return mixed */ |
89 | 89 | |
90 | - static function content($dir, array $options=null) { |
|
90 | + static function content($dir, array $options = null){ |
|
91 | 91 | |
92 | 92 | $defaultOptions = array( |
93 | - 'types' => "all", // Allowed: "all" or possible return values |
|
93 | + 'types' => "all", // Allowed: "all" or possible return values |
|
94 | 94 | // of filetype(), or an array with them |
95 | - 'addPath' => true, // Whether to add directory path to filenames |
|
95 | + 'addPath' => true, // Whether to add directory path to filenames |
|
96 | 96 | 'pattern' => '/./', // Regular expression pattern for filename |
97 | 97 | 'followLinks' => true |
98 | 98 | ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return $files; |
146 | 146 | } |
147 | 147 | |
148 | - static function fileSort($a, $b) { |
|
148 | + static function fileSort($a, $b){ |
|
149 | 149 | if (function_exists("mb_strtolower")) { |
150 | 150 | $a = mb_strtolower($a); |
151 | 151 | $b = mb_strtolower($b); |
@@ -12,23 +12,27 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class dir { |
|
15 | +class dir |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** Checks if the given directory is really writable. The standard PHP |
18 | 19 | * function is_writable() does not work properly on Windows servers |
19 | 20 | * @param string $dir |
20 | 21 | * @return bool */ |
21 | 22 | |
22 | - static function isWritable($dir) { |
|
23 | + static function isWritable($dir) |
|
24 | + { |
|
23 | 25 | $dir = path::normalize($dir); |
24 | - if (!is_dir($dir)) |
|
25 | - return false; |
|
26 | + if (!is_dir($dir)) { |
|
27 | + return false; |
|
28 | + } |
|
26 | 29 | $i = 0; |
27 | 30 | do { |
28 | 31 | $file = "$dir/is_writable_" . md5($i++); |
29 | 32 | } while (file_exists($file)); |
30 | - if (!@touch($file)) |
|
31 | - return false; |
|
33 | + if (!@touch($file)) { |
|
34 | + return false; |
|
35 | + } |
|
32 | 36 | unlink($file); |
33 | 37 | return true; |
34 | 38 | } |
@@ -44,12 +48,16 @@ discard block |
||
44 | 48 | * @param array $failed |
45 | 49 | * @return mixed */ |
46 | 50 | |
47 | - static function prune($dir, $firstFailExit=true, array $failed=null) { |
|
48 | - if ($failed === null) $failed = array(); |
|
51 | + static function prune($dir, $firstFailExit=true, array $failed=null) |
|
52 | + { |
|
53 | + if ($failed === null) { |
|
54 | + $failed = array(); |
|
55 | + } |
|
49 | 56 | $files = self::content($dir); |
50 | 57 | if ($files === false) { |
51 | - if ($firstFailExit) |
|
52 | - return $dir; |
|
58 | + if ($firstFailExit) { |
|
59 | + return $dir; |
|
60 | + } |
|
53 | 61 | $failed[] = $dir; |
54 | 62 | return $failed; |
55 | 63 | } |
@@ -58,23 +66,27 @@ discard block |
||
58 | 66 | if (is_dir($file)) { |
59 | 67 | $failed_in = self::prune($file, $firstFailExit, $failed); |
60 | 68 | if ($failed_in !== true) { |
61 | - if ($firstFailExit) |
|
62 | - return $failed_in; |
|
63 | - if (is_array($failed_in)) |
|
64 | - $failed = array_merge($failed, $failed_in); |
|
65 | - else |
|
66 | - $failed[] = $failed_in; |
|
69 | + if ($firstFailExit) { |
|
70 | + return $failed_in; |
|
71 | + } |
|
72 | + if (is_array($failed_in)) { |
|
73 | + $failed = array_merge($failed, $failed_in); |
|
74 | + } else { |
|
75 | + $failed[] = $failed_in; |
|
76 | + } |
|
67 | 77 | } |
68 | 78 | } elseif (!@unlink($file)) { |
69 | - if ($firstFailExit) |
|
70 | - return $file; |
|
79 | + if ($firstFailExit) { |
|
80 | + return $file; |
|
81 | + } |
|
71 | 82 | $failed[] = $file; |
72 | 83 | } |
73 | 84 | } |
74 | 85 | |
75 | 86 | if (!@rmdir($dir)) { |
76 | - if ($firstFailExit) |
|
77 | - return $dir; |
|
87 | + if ($firstFailExit) { |
|
88 | + return $dir; |
|
89 | + } |
|
78 | 90 | $failed[] = $dir; |
79 | 91 | } |
80 | 92 | |
@@ -87,7 +99,8 @@ discard block |
||
87 | 99 | * @param array $options |
88 | 100 | * @return mixed */ |
89 | 101 | |
90 | - static function content($dir, array $options=null) { |
|
102 | + static function content($dir, array $options=null) |
|
103 | + { |
|
91 | 104 | |
92 | 105 | $defaultOptions = array( |
93 | 106 | 'types' => "all", // Allowed: "all" or possible return values |
@@ -97,23 +110,28 @@ discard block |
||
97 | 110 | 'followLinks' => true |
98 | 111 | ); |
99 | 112 | |
100 | - if (!is_dir($dir) || !is_readable($dir)) |
|
101 | - return false; |
|
113 | + if (!is_dir($dir) || !is_readable($dir)) { |
|
114 | + return false; |
|
115 | + } |
|
102 | 116 | |
103 | - if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") |
|
104 | - $dir = str_replace("\\", "/", $dir); |
|
117 | + if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
|
118 | + $dir = str_replace("\\", "/", $dir); |
|
119 | + } |
|
105 | 120 | $dir = rtrim($dir, "/"); |
106 | 121 | |
107 | 122 | $dh = @opendir($dir); |
108 | - if ($dh === false) |
|
109 | - return false; |
|
123 | + if ($dh === false) { |
|
124 | + return false; |
|
125 | + } |
|
110 | 126 | |
111 | - if ($options === null) |
|
112 | - $options = $defaultOptions; |
|
127 | + if ($options === null) { |
|
128 | + $options = $defaultOptions; |
|
129 | + } |
|
113 | 130 | |
114 | - foreach ($defaultOptions as $key => $val) |
|
115 | - if (!isset($options[$key])) |
|
131 | + foreach ($defaultOptions as $key => $val) { |
|
132 | + if (!isset($options[$key])) |
|
116 | 133 | $options[$key] = $val; |
134 | + } |
|
117 | 135 | |
118 | 136 | $files = array(); |
119 | 137 | while (($file = @readdir($dh)) !== false) { |
@@ -124,28 +142,32 @@ discard block |
||
124 | 142 | do { |
125 | 143 | $ldir = dirname($lfile); |
126 | 144 | $lfile = @readlink($lfile); |
127 | - if (substr($lfile, 0, 1) != "/") |
|
128 | - $lfile = "$ldir/$lfile"; |
|
145 | + if (substr($lfile, 0, 1) != "/") { |
|
146 | + $lfile = "$ldir/$lfile"; |
|
147 | + } |
|
129 | 148 | $type = filetype($lfile); |
130 | 149 | } while ($type == "link"); |
131 | 150 | } |
132 | 151 | |
133 | 152 | if ((($type === "dir") && (($file == ".") || ($file == ".."))) || |
134 | 153 | !preg_match($options['pattern'], $file) |
135 | - ) |
|
136 | - continue; |
|
154 | + ) { |
|
155 | + continue; |
|
156 | + } |
|
137 | 157 | |
138 | 158 | if (($options['types'] === "all") || ($type === $options['types']) || |
139 | 159 | ((is_array($options['types'])) && in_array($type, $options['types'])) |
140 | - ) |
|
141 | - $files[] = $options['addPath'] ? "$dir/$file" : $file; |
|
160 | + ) { |
|
161 | + $files[] = $options['addPath'] ? "$dir/$file" : $file; |
|
162 | + } |
|
142 | 163 | } |
143 | 164 | closedir($dh); |
144 | 165 | usort($files, array("dir", "fileSort")); |
145 | 166 | return $files; |
146 | 167 | } |
147 | 168 | |
148 | - static function fileSort($a, $b) { |
|
169 | + static function fileSort($a, $b) |
|
170 | + { |
|
149 | 171 | if (function_exists("mb_strtolower")) { |
150 | 172 | $a = mb_strtolower($a); |
151 | 173 | $b = mb_strtolower($b); |
@@ -153,7 +175,9 @@ discard block |
||
153 | 175 | $a = strtolower($a); |
154 | 176 | $b = strtolower($b); |
155 | 177 | } |
156 | - if ($a == $b) return 0; |
|
178 | + if ($a == $b) { |
|
179 | + return 0; |
|
180 | + } |
|
157 | 181 | return ($a < $b) ? -1 : 1; |
158 | 182 | } |
159 | 183 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc ImageMagick image driver 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 ImageMagick image driver 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 image_imagick extends image { |
16 | 16 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_imagick extends image { |
|
15 | +class image_imagick extends image{ |
|
16 | 16 | |
17 | 17 | static $MIMES = array( |
18 | 18 | //'tif' => "image/tiff" |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | // ABSTRACT PUBLIC METHODS |
23 | 23 | |
24 | - public function resize($width, $height) {// |
|
24 | + public function resize($width, $height){// |
|
25 | 25 | if (!$width) $width = 1; |
26 | 26 | if (!$height) $height = 1; |
27 | 27 | try { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
37 | + public function resizeFit($width, $height, $background = false){// |
|
38 | 38 | if (!$width) $width = 1; |
39 | 39 | if (!$height) $height = 1; |
40 | 40 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function resizeCrop($width, $height, $offset=false) { |
|
68 | + public function resizeCrop($width, $height, $offset = false){ |
|
69 | 69 | if (!$width) $width = 1; |
70 | 70 | if (!$height) $height = 1; |
71 | 71 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | |
118 | - public function rotate($angle, $background="#000000") { |
|
118 | + public function rotate($angle, $background = "#000000"){ |
|
119 | 119 | try { |
120 | 120 | $this->image->rotateImage(new ImagickPixel($background), $angle); |
121 | 121 | $size = $this->image->getImageGeometry(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return true; |
128 | 128 | } |
129 | 129 | |
130 | - public function flipHorizontal() { |
|
130 | + public function flipHorizontal(){ |
|
131 | 131 | try { |
132 | 132 | $this->image->flopImage(); |
133 | 133 | } catch (Exception $e) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
139 | - public function flipVertical() { |
|
139 | + public function flipVertical(){ |
|
140 | 140 | try { |
141 | 141 | $this->image->flipImage(); |
142 | 142 | } catch (Exception $e) { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | |
148 | - public function watermark($file, $left=false, $top=false) { |
|
148 | + public function watermark($file, $left = false, $top = false){ |
|
149 | 149 | try { |
150 | 150 | $wm = new Imagick($file); |
151 | 151 | $size = $wm->getImageGeometry(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | // ABSTRACT PROTECTED METHODS |
183 | 183 | |
184 | - protected function getBlankImage($width, $height) { |
|
184 | + protected function getBlankImage($width, $height){ |
|
185 | 185 | try { |
186 | 186 | $img = new Imagick(); |
187 | 187 | $img->newImage($width, $height, "none"); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | return $img; |
193 | 193 | } |
194 | 194 | |
195 | - protected function getImage($image, &$width, &$height) { |
|
195 | + protected function getImage($image, &$width, &$height){ |
|
196 | 196 | |
197 | 197 | if (is_object($image) && ($image instanceof image_imagick)) { |
198 | 198 | try { |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | |
235 | 235 | // PSEUDO-ABSTRACT STATIC METHODS |
236 | 236 | |
237 | - static function available() { |
|
237 | + static function available(){ |
|
238 | 238 | return class_exists("Imagick"); |
239 | 239 | } |
240 | 240 | |
241 | - static function checkImage($file) { |
|
241 | + static function checkImage($file){ |
|
242 | 242 | try { |
243 | 243 | new Imagick($file); |
244 | 244 | } catch (Exception $e) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | // INHERIT METHODS |
252 | 252 | |
253 | - public function output($type="jpeg", array $options=array()) { |
|
253 | + public function output($type = "jpeg", array $options = array()){ |
|
254 | 254 | $type = strtolower($type); |
255 | 255 | try { |
256 | 256 | $this->image->setImageFormat($type); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | echo $this->image; |
270 | 270 | |
271 | 271 | } else { |
272 | - $file = $options['file'] . ".$type"; |
|
272 | + $file = $options['file'].".$type"; |
|
273 | 273 | try { |
274 | 274 | $this->image->writeImage($file); |
275 | 275 | } catch (Exception $e) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | // OWN METHODS |
291 | 291 | |
292 | - protected function optimize_jpeg(array $options=array()) { |
|
292 | + protected function optimize_jpeg(array $options = array()){ |
|
293 | 293 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
294 | 294 | try { |
295 | 295 | $this->image->setImageCompression(Imagick::COMPRESSION_JPEG); |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_imagick extends image { |
|
15 | +class image_imagick extends image |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | static $MIMES = array( |
18 | 19 | //'tif' => "image/tiff" |
@@ -21,9 +22,15 @@ discard block |
||
21 | 22 | |
22 | 23 | // ABSTRACT PUBLIC METHODS |
23 | 24 | |
24 | - public function resize($width, $height) {// |
|
25 | - if (!$width) $width = 1; |
|
26 | - if (!$height) $height = 1; |
|
25 | + public function resize($width, $height) |
|
26 | + { |
|
27 | +// |
|
28 | + if (!$width) { |
|
29 | + $width = 1; |
|
30 | + } |
|
31 | + if (!$height) { |
|
32 | + $height = 1; |
|
33 | + } |
|
27 | 34 | try { |
28 | 35 | $this->image->scaleImage($width, $height); |
29 | 36 | } catch (Exception $e) { |
@@ -34,9 +41,15 @@ discard block |
||
34 | 41 | return true; |
35 | 42 | } |
36 | 43 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
38 | - if (!$width) $width = 1; |
|
39 | - if (!$height) $height = 1; |
|
44 | + public function resizeFit($width, $height, $background=false) |
|
45 | + { |
|
46 | +// |
|
47 | + if (!$width) { |
|
48 | + $width = 1; |
|
49 | + } |
|
50 | + if (!$height) { |
|
51 | + $height = 1; |
|
52 | + } |
|
40 | 53 | |
41 | 54 | try { |
42 | 55 | $this->image->scaleImage($width, $height, true); |
@@ -65,43 +78,58 @@ discard block |
||
65 | 78 | } |
66 | 79 | } |
67 | 80 | |
68 | - public function resizeCrop($width, $height, $offset=false) { |
|
69 | - if (!$width) $width = 1; |
|
70 | - if (!$height) $height = 1; |
|
81 | + public function resizeCrop($width, $height, $offset=false) |
|
82 | + { |
|
83 | + if (!$width) { |
|
84 | + $width = 1; |
|
85 | + } |
|
86 | + if (!$height) { |
|
87 | + $height = 1; |
|
88 | + } |
|
71 | 89 | |
72 | 90 | if (($this->width / $this->height) > ($width / $height)) { |
73 | 91 | $h = $height; |
74 | 92 | $w = ($this->width * $h) / $this->height; |
75 | 93 | $y = 0; |
76 | 94 | if ($offset !== false) { |
77 | - if ($offset > 0) |
|
78 | - $offset = -$offset; |
|
79 | - if (($w + $offset) <= $width) |
|
80 | - $offset = $width - $w; |
|
95 | + if ($offset > 0) { |
|
96 | + $offset = -$offset; |
|
97 | + } |
|
98 | + if (($w + $offset) <= $width) { |
|
99 | + $offset = $width - $w; |
|
100 | + } |
|
81 | 101 | $x = $offset; |
82 | - } else |
|
83 | - $x = ($width - $w) / 2; |
|
102 | + } else { |
|
103 | + $x = ($width - $w) / 2; |
|
104 | + } |
|
84 | 105 | |
85 | 106 | } else { |
86 | 107 | $w = $width; |
87 | 108 | $h = ($this->height * $w) / $this->width; |
88 | 109 | $x = 0; |
89 | 110 | if ($offset !== false) { |
90 | - if ($offset > 0) |
|
91 | - $offset = -$offset; |
|
92 | - if (($h + $offset) <= $height) |
|
93 | - $offset = $height - $h; |
|
111 | + if ($offset > 0) { |
|
112 | + $offset = -$offset; |
|
113 | + } |
|
114 | + if (($h + $offset) <= $height) { |
|
115 | + $offset = $height - $h; |
|
116 | + } |
|
94 | 117 | $y = $offset; |
95 | - } else |
|
96 | - $y = ($height - $h) / 2; |
|
118 | + } else { |
|
119 | + $y = ($height - $h) / 2; |
|
120 | + } |
|
97 | 121 | } |
98 | 122 | |
99 | 123 | $x = round($x); |
100 | 124 | $y = round($y); |
101 | 125 | $w = round($w); |
102 | 126 | $h = round($h); |
103 | - if (!$w) $w = 1; |
|
104 | - if (!$h) $h = 1; |
|
127 | + if (!$w) { |
|
128 | + $w = 1; |
|
129 | + } |
|
130 | + if (!$h) { |
|
131 | + $h = 1; |
|
132 | + } |
|
105 | 133 | |
106 | 134 | try { |
107 | 135 | $this->image->scaleImage($w, $h); |
@@ -115,7 +143,8 @@ discard block |
||
115 | 143 | return true; |
116 | 144 | } |
117 | 145 | |
118 | - public function rotate($angle, $background="#000000") { |
|
146 | + public function rotate($angle, $background="#000000") |
|
147 | + { |
|
119 | 148 | try { |
120 | 149 | $this->image->rotateImage(new ImagickPixel($background), $angle); |
121 | 150 | $size = $this->image->getImageGeometry(); |
@@ -127,7 +156,8 @@ discard block |
||
127 | 156 | return true; |
128 | 157 | } |
129 | 158 | |
130 | - public function flipHorizontal() { |
|
159 | + public function flipHorizontal() |
|
160 | + { |
|
131 | 161 | try { |
132 | 162 | $this->image->flopImage(); |
133 | 163 | } catch (Exception $e) { |
@@ -136,7 +166,8 @@ discard block |
||
136 | 166 | return true; |
137 | 167 | } |
138 | 168 | |
139 | - public function flipVertical() { |
|
169 | + public function flipVertical() |
|
170 | + { |
|
140 | 171 | try { |
141 | 172 | $this->image->flipImage(); |
142 | 173 | } catch (Exception $e) { |
@@ -145,7 +176,8 @@ discard block |
||
145 | 176 | return true; |
146 | 177 | } |
147 | 178 | |
148 | - public function watermark($file, $left=false, $top=false) { |
|
179 | + public function watermark($file, $left=false, $top=false) |
|
180 | + { |
|
149 | 181 | try { |
150 | 182 | $wm = new Imagick($file); |
151 | 183 | $size = $wm->getImageGeometry(); |
@@ -167,8 +199,9 @@ discard block |
||
167 | 199 | if ((($x + $w) > $this->width) || |
168 | 200 | (($y + $h) > $this->height) || |
169 | 201 | ($x < 0) || ($y < 0) |
170 | - ) |
|
171 | - return false; |
|
202 | + ) { |
|
203 | + return false; |
|
204 | + } |
|
172 | 205 | |
173 | 206 | try { |
174 | 207 | $this->image->compositeImage($wm, Imagick::COMPOSITE_DEFAULT, $x, $y); |
@@ -181,7 +214,8 @@ discard block |
||
181 | 214 | |
182 | 215 | // ABSTRACT PROTECTED METHODS |
183 | 216 | |
184 | - protected function getBlankImage($width, $height) { |
|
217 | + protected function getBlankImage($width, $height) |
|
218 | + { |
|
185 | 219 | try { |
186 | 220 | $img = new Imagick(); |
187 | 221 | $img->newImage($width, $height, "none"); |
@@ -192,7 +226,8 @@ discard block |
||
192 | 226 | return $img; |
193 | 227 | } |
194 | 228 | |
195 | - protected function getImage($image, &$width, &$height) { |
|
229 | + protected function getImage($image, &$width, &$height) |
|
230 | + { |
|
196 | 231 | |
197 | 232 | if (is_object($image) && ($image instanceof image_imagick)) { |
198 | 233 | try { |
@@ -227,18 +262,21 @@ discard block |
||
227 | 262 | $height = $size['height']; |
228 | 263 | return $image; |
229 | 264 | |
230 | - } else |
|
231 | - return false; |
|
265 | + } else { |
|
266 | + return false; |
|
267 | + } |
|
232 | 268 | } |
233 | 269 | |
234 | 270 | |
235 | 271 | // PSEUDO-ABSTRACT STATIC METHODS |
236 | 272 | |
237 | - static function available() { |
|
273 | + static function available() |
|
274 | + { |
|
238 | 275 | return class_exists("Imagick"); |
239 | 276 | } |
240 | 277 | |
241 | - static function checkImage($file) { |
|
278 | + static function checkImage($file) |
|
279 | + { |
|
242 | 280 | try { |
243 | 281 | new Imagick($file); |
244 | 282 | } catch (Exception $e) { |
@@ -250,7 +288,8 @@ discard block |
||
250 | 288 | |
251 | 289 | // INHERIT METHODS |
252 | 290 | |
253 | - public function output($type="jpeg", array $options=array()) { |
|
291 | + public function output($type="jpeg", array $options=array()) |
|
292 | + { |
|
254 | 293 | $type = strtolower($type); |
255 | 294 | try { |
256 | 295 | $this->image->setImageFormat($type); |
@@ -258,8 +297,9 @@ discard block |
||
258 | 297 | return false; |
259 | 298 | } |
260 | 299 | $method = "optimize_$type"; |
261 | - if (method_exists($this, $method) && !$this->$method($options)) |
|
262 | - return false; |
|
300 | + if (method_exists($this, $method) && !$this->$method($options)) { |
|
301 | + return false; |
|
302 | + } |
|
263 | 303 | |
264 | 304 | if (!isset($options['file'])) { |
265 | 305 | if (!headers_sent()) { |
@@ -289,7 +329,8 @@ discard block |
||
289 | 329 | |
290 | 330 | // OWN METHODS |
291 | 331 | |
292 | - protected function optimize_jpeg(array $options=array()) { |
|
332 | + protected function optimize_jpeg(array $options=array()) |
|
333 | + { |
|
293 | 334 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
294 | 335 | try { |
295 | 336 | $this->image->setImageCompression(Imagick::COMPRESSION_JPEG); |