/** * * @return string */ public static function fileTree() { $root = JchPlatformPaths::rootPath(); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir); $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= '<ul class="jqueryFileTree" style="display: none; ">'; // All dirs foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file . '/') . '">' . htmlentities($file) . '</a></li>'; } } // All files foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file) . '">' . htmlentities($file) . '</a></li>'; } } $response .= '</ul>'; } } return $response; }
/** * * @return string */ public static function fileTree() { $root = rtrim(JchPlatformPaths::rootPath(), '/\\'); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $view = urldecode(JchPlatformUtility::get('view', '', 'string', 'post')); $initial = urldecode(JchPlatformUtility::get('initial', '0', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir) . '/'; if ($view != 'tree') { $header = '<div id="files-container-header"><ul class="jqueryFileTree"><li><span><root>' . $dir . '</span></li>'; $header .= '<li class="check-all"><span><input type="checkbox"></span><span><em>Check all</em></span>' . '<span><em>' . JchPlatformUtility::translate('Width') . ' (px)</em></span>' . '<span><em>' . JchPlatformUtility::translate('Height') . ' (px)</em></span></li></ul></div><div class="files-content">'; $display = ''; } else { $display = 'style="display: none;"'; $header = ''; } $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); // $files = JchPlatformUtility::lsFiles($root . $dir, '\.(?:gif|jpe?g|png)$', FALSE); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= ''; $response = $header; if ($initial && $view == 'tree') { $response .= '<div class="files-content"><ul class="jqueryFileTree">'; $response .= '<li class="directory expanded"><a href="#" rel=""><root></a>'; } $response .= '<ul class="jqueryFileTree" ' . $display . '>'; foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed">' . self::item($file, $dir, $view, 'dir') . '</li>'; } } // All files if ($view != 'tree') { foreach ($files as $file) { if (file_exists($root . $dir . $file) && preg_match('#\\.(?:gif|jpe?g|png|GIF|JPE?G|PNG)$#', $file) && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . strtolower($ext) . '">' . self::item($file, $dir, $view, 'file') . '</li>'; } } } $response .= '</ul>'; if ($initial && $view == 'tree') { $response .= '</li></ul></div>'; } } } return $response; }