private function _themeTree($directory, $return_link, $parent = '')
{
$current_path = $this->input->get('file') ? explode('/', $this->input->get('file')) : array();
$theme_tree = '';
$theme_tree .= $parent === '' ? '<nav class="nav"><ul class="metisFolder">' : '<ul>';
$theme_files = find_theme_files($directory);
if (!empty($theme_files)) {
foreach ($theme_files as $file) {
$active = in_array($file['name'], $current_path) ? ' active' : '';
if ($file['type'] === 'dir') {
$parent_dir = $parent . '/' . $file['name'];
$theme_tree .= '<li class="directory' . $active . '"><a><i class="fa fa-folder-open"></i> ' . htmlspecialchars($file['name']) . '</a>';
$theme_tree .= $this->_themeTree($directory . '/' . $file['name'], $return_link, $parent_dir);
$theme_tree .= '</li>';
} else {
if ($file['type'] === 'img') {
$link = str_replace('{link}', $parent . '/' . urlencode($file['name']), $return_link);
$theme_tree .= '<li class="img' . $active . '"><a href="' . $link . '"><i class="fa fa-file-image-o"></i> ' . htmlspecialchars($file['name']) . '</a></li>';
} else {
if ($file['type'] === 'file') {
$link = str_replace('{link}', $parent . '/' . urlencode($file['name']), $return_link);
$theme_tree .= '<li class="file' . $active . '"><a href="' . $link . '"><i class="fa fa-file-code-o"></i> ' . htmlspecialchars($file['name']) . '</a></li>';
}
}
}
}
}
$theme_tree .= '</ul>';
if ($parent === '') {
$theme_tree .= '</nav>';
}
return $theme_tree;
}