Ejemplo n.º 1
0
    /**
     * Create HTML representation of file system tree
     *
     * This function creates the file manager HTML code. It also handles any AJAX calls,
     * composes and prints upload and create directory forms, as well as makes sure the
     * correct folder contents are displayed.
     * <code>
     * $basedir    = G_LESSONSPATH.'test/';
     * $filesystem = new FileSystemTree($basedir);									//Set the base directory that the file manager displayes
     * $url        = 'administrator.php?ctg=file_manager';			//Set the url where file manager resides
     * echo $filesystem -> toHTML($url); 											//Display file manager
     * </code>
     * The available options are (the default value in parenthesis):
     * - show_type (true)				//Whether to show the "type" column
     * - show_date (true)				//Whether to show the "last modified" column
     * - show_name (true)				//Whether to show the "name" column
     * - show_size (true)				//Whether to show the "size" column
     * - show_tools (true)				//Whether to show the "tools" column
     * - metadata (true)				//Whether to allow for metadata
     * - db_files_only (false) 			//Whether to display only files that have a db representation
     * - delete (true)					//Whether to display delete icon
     * - download (true)				//Whether to display download icon
     * - zip  (true)					//Whether to display zip icon
     * - share (true)					//Whether to display share icon
     * - create_folder (true)			//Whether to display create folder link
     * - upload (true)					//Whether to display upload file link
     * - copy (true)					//Whether to display copy icon
     * - folders (true)					//Whether to display folders in files list
     *
     * The $extraFileTools, $extraHeaderOptions, $extraDirectoryTools paramaters are used to add custom
     * extra tools to various places of the file manager. The format of these parameters is of the form:
     * $extraFileTools = array(array('image' => 'images/16x16/restore.png', 'title' => _RESTORE, 'action' => 'restore'));
     * $extraHeaderOptions = array(array('image' => 'images/16x16/undo.png', 'title' => _BACKUP, 'action' => 'backup'));
     *
     * @param string $url The url where the file manager resides
     * @param string $currentDirectory The directory to use as base directory
     * @param array $ajaxOptions AJAX-specific options: sort, order, limit, offset, filter
     * @param array $options Options for the file manager
     * @param array $extraFileTools Extra tools for files
     * @param array $extraDirectoryTools Extra tools for directories
     * @param array $extraHeaderOptions Extra tools for file manager header
     * @param array $defaultIterator A specific iterator to use for files display
     * @param bool 	$show_tooltip If tooltip is dislayed in name
     * @return string The HTML representation of the file system
     * @since 3.5.0
     * @access public
     */
    public function toHTML($url, $currentDirectory = '', $ajaxOptions = array(), $options, $extraFileTools = array(), $extraDirectoryTools = array(), $extraHeaderOptions = array(), $defaultIterator = false, $show_tooltip = true, $extraColumns = array())
    {
        //Set default options
        !isset($options['show_type']) ? $options['show_type'] = true : null;
        !isset($options['show_date']) ? $options['show_date'] = true : null;
        !isset($options['show_name']) ? $options['show_name'] = true : null;
        !isset($options['show_size']) ? $options['show_size'] = true : null;
        !isset($options['show_tools']) ? $options['show_tools'] = true : null;
        !isset($options['delete']) ? $options['delete'] = true : null;
        !isset($options['download']) ? $options['download'] = true : null;
        !isset($options['zip']) ? $options['zip'] = true : null;
        !isset($options['share']) ? $options['share'] = true : null;
        !isset($options['edit']) ? $options['edit'] = true : null;
        !isset($options['copy']) ? $options['copy'] = true : null;
        !isset($options['create_folder']) ? $options['create_folder'] = true : null;
        !isset($options['upload']) ? $options['upload'] = true : null;
        !isset($options['folders']) ? $options['folders'] = true : null;
        !isset($options['db_files_only']) ? $options['db_files_only'] = false : null;
        !isset($options['table_id']) ? $tableId = 'filesTable' : ($tableId = $options['table_id']);
        //Make sure that current directory is a path
        //$currentDirectory = new EfrontDirectory($currentDirectory);
        if ($currentDirectory instanceof EfrontDirectory) {
            $currentDirectory = $currentDirectory['path'];
        }
        if (isset($_POST['upload_current_directory']) && strpos(EfrontDirectory::normalize($_POST['upload_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['upload_current_directory'];
        }
        if (isset($_POST['current_directory']) && strpos(EfrontDirectory::normalize($_POST['current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['current_directory'];
        }
        if (isset($_POST['copy_current_directory']) && strpos(EfrontDirectory::normalize($_POST['copy_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['copy_current_directory'];
        }
        if ($currentDirectory && $currentDirectory != $this->dir['path']) {
            //Check that the current directory actually exists
            $currentDir = new EfrontDirectory($currentDirectory);
            //Get its parent directory
            $parentDir = new EfrontDirectory($currentDir['directory']);
            //Build a new (shallow) file system tree on the current directory
            $innerFileSystem = new FileSystemTree($currentDir, false);
            //Assign each node as a child to the currentDir, thus creating a new tree with currentDir as parent
            foreach ($innerFileSystem->tree as $key => $value) {
                $currentDir[$key] = $value;
            }
            //$currentDir = $this -> seekNode($currentDirectory);
            //$parentDir  = new EfrontDirectory($currentDir['directory']);
        } else {
            $currentDirectory = $this->dir['path'];
            $currentDir = $this->tree;
        }
        try {
            $uploadForm = new HTML_QuickForm("upload_file_form_{$tableId}", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $uploadFormString = $this->getUploadForm($uploadForm);
            if ($uploadForm->isSubmitted() && $uploadForm->validate()) {
                $uploadedFile = $this->handleUploadForm($uploadForm);
                $uploadFormString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');parent.$(\'uploading_image\').hide()}</script>';
            }
            $createFolderForm = new HTML_QuickForm("create_folder_form", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $createFolderString = $this->getCreateDirectoryForm($createFolderForm);
            if ($createFolderForm->isSubmitted() && $createFolderForm->validate()) {
                $this->handleCreateDirectoryForm($createFolderForm);
                $createFolderString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');}</script>';
            }
            /*
            $copyForm       = new HTML_QuickForm("copy_file_form", "post", $url, "", "", true);
            
            foreach ($iterator = new EfrontDirectoryOnlyFilterIterator(new EfrontNodeFilterIterator($currentDir)) as $key => $value) {
            $directories[$key] = str_replace($this -> dir['path'].'/', '', EfrontFile :: decode($value['path']));
            }
            $copyForm -> addElement('select', 'destination', null, $directories, 'class = "inputText"');
            $copyFormString = $this -> getCopyForm($copyForm);
            
            if ($copyForm -> isSubmitted() && $copyForm -> validate()) {
            $copiedFile = $this -> handleCopyForm($copyForm);
            }
            */
            //pr($currentDirectory);
            if (isset($_POST['copy_files']) && sizeof($_POST['copy_files']) > 0) {
                $copyFiles = explode(",", $_POST["copy_files"]);
                foreach ($copyFiles as $file) {
                    $file = new EfrontFile($file);
                    //pr('copying to '.$currentDirectory.'/'.basename($file['path']));
                    $file->copy($currentDirectory . '/' . basename($file['path']));
                }
            }
        } catch (Exception $e) {
            echo "<script>if (top && top.mainframe) {w=top.mainframe} else {w=parent;}w.document.getElementById('messageError').innerHTML = '" . $e->getMessage() . "';parent.\$('uploading_image').hide();</script>";
            //Don't halt for uploading and create directory errors
            $GLOBALS['smarty']->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
            $GLOBALS['message'] = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        }
        $files = array();
        $fileArrays = array();
        $foldersArray = array();
        $filesArray = array();
        if ($options['folders']) {
            $iterator = new EfrontDirectoryOnlyFilterIterator(new ArrayIterator($currentDir));
            //Plain ArrayIterator so that it iterates only on the current's folder files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
            foreach ($iterator as $key => $value) {
                //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
                $current = (array) $iterator->current();
                foreach ($current as $k => $v) {
                    //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                    if ($v instanceof ArrayObject) {
                        unset($current[$k]);
                    }
                }
                $current['size'] = 0;
                $current['extension'] = '';
                $current['shared'] = 10;
                //Add these 3 parameters, so that sorting below works correctly (10 means nothing, since a folder cannot be shared, but it is handy for sorting)
                $foldersArray[] = (array) $current;
                //Array representation of directory objects, on which we can apply sorting, filtering, etc
            }
            $foldersArray = eF_multiSort($foldersArray, 'name', 'asc');
        }
        if ($defaultIterator) {
            $iterator = $defaultIterator;
        } else {
            $iterator = new EfrontFileOnlyFilterIterator(new EfrontNodeFilterIterator(new ArrayIterator($currentDir)));
            //Plain ArrayIterator so that it iterates only on the current folder's files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
        }
        foreach ($iterator as $key => $value) {
            //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
            $current = (array) $iterator->current();
            foreach ($current as $k => $v) {
                //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                if ($v instanceof ArrayObject) {
                    unset($current[$k]);
                }
            }
            $filesArray[] = (array) $current;
            //Array representation of file objects, on which we can apply sorting, filtering, etc
        }
        $filesArray = eF_multiSort($filesArray, 'name', 'asc');
        $fileArrays = array_merge($foldersArray, $filesArray);
        isset($ajaxOptions['order']) && $ajaxOptions['order'] == 'asc' ? $ajaxOptions['order'] = 'asc' : ($ajaxOptions['order'] = 'desc');
        !isset($ajaxOptions['sort']) ? $ajaxOptions['sort'] = 'name' : null;
        !isset($ajaxOptions['limit']) ? $ajaxOptions['limit'] = 20 : null;
        !isset($ajaxOptions['offset']) ? $ajaxOptions['offset'] = 0 : null;
        !isset($ajaxOptions['filter']) ? $ajaxOptions['filter'] = '' : null;
        $size = sizeof($fileArrays);
        if ($size) {
            $fileArrays = eF_multiSort($fileArrays, $ajaxOptions['sort'], $ajaxOptions['order']);
            $ajaxOptions['filter'] ? $fileArrays = eF_filterData($fileArrays, $ajaxOptions['filter']) : null;
            $fileArrays = array_slice($fileArrays, $ajaxOptions['offset'], $ajaxOptions['limit']);
        }
        $extraColumnsString = '';
        foreach ($extraColumns as $value) {
            $extraColumnsString = '<td class = "topTitle centerAlign" name = "' . $value . '">' . $value . '</td>';
        }
        $filesCode = '
                        <table class = "sortedTable" style = "width:100%" size = "' . $size . '" id = "' . $tableId . '" useAjax = "1" rowsPerPage = "20" other = "' . urlencode($currentDirectory) . '" url = "' . $url . '&" nomass = "1" currentDir = "' . (isset($currentDir['path']) ? $currentDir['path'] : '') . '">
                    		<tr>' . ($options['show_type'] ? '<td class = "topTitle centerAlign" name = "extension">' . _TYPE . '</td>' : '') . '
                    			' . ($options['show_name'] ? '<td class = "topTitle" name = "name" id = "filename_' . $tableId . '">' . _NAME . '</td>' : '') . '
                    			' . ($options['show_size'] ? '<td class = "topTitle" name = "size">' . _SIZE . '</td>' : '') . '
                    			' . ($options['show_date'] ? '<td class = "topTitle" name = "timestamp">' . _MODIFIED . '</td>' : '') . '
								' . $extraColumnsString . '
                    			' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign" name = "shared">' . _SHARE . '</td>' : '') . '
                    			' . ($options['show_tools'] ? '<td class = "topTitle centerAlign noSort">' . _OPERATIONS . '</td>' : '') . '
                    			' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign">' . _SELECT . '</td>' : '') . '
                    		</tr>';
        if (isset($parentDir)) {
            if ($parentDir['path'] == $this->dir['path']) {
                $parentDir['path'] = '';
            }
            $filesCode .= '
            			<tr class = "defaultRowHeight eventRowColor"><td class = "centerAlign" colspan = "100%">' . _CURRENTLYBROWSINGFOLDER . ': ' . EfrontFile::decode(str_replace($this->dir['path'], '', $currentDir['path'])) . '</td></tr>
                    	<tr class = "defaultRowHeight oddRowColor">
                    		<td class = "centerAlign"><span style = "display:none"></span><img src = "images/16x16/folder_up.png" alt = "' . _UPONELEVEL . '" title = "' . _UPONELEVEL . '"/></td>
                    		<td><a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($parentDir['path']) . '\');">.. (' . _UPONELEVEL . ')</a></td>
                    		<td colspan = "5"></td></tr>';
        }
        $i = 0;
        if ($_SESSION['supervises_branches'] != "") {
            $currentEmployee = EfrontUserFactory::factory($_SESSION['s_login']);
            $employees = eF_getTableData("users LEFT OUTER JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_LOGIN LEFT OUTER JOIN module_hcd_employee_works_at_branch ON users.login = module_hcd_employee_works_at_branch.users_LOGIN", "users.*, count(job_description_ID) as jobs_num", " users.user_type <> 'administrator' AND ((module_hcd_employee_works_at_branch.branch_ID IN (" . $_SESSION['supervises_branches'] . " ) AND module_hcd_employee_works_at_branch.assigned='1') OR EXISTS (SELECT module_hcd_employees.users_login FROM module_hcd_employees LEFT OUTER JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = module_hcd_employees.users_login WHERE users.login=module_hcd_employees.users_login AND module_hcd_employee_works_at_branch.branch_ID IS NULL)) GROUP BY login", "login");
            $supervisedLogins = array();
            foreach ($employees as $key2 => $value2) {
                if (!$value2['active'] || $value2['archive'] || !$value2['jobs_num']) {
                    unset($employees[$key2]);
                } else {
                    $supervisedLogins[] = $value2['login'];
                }
            }
        }
        foreach ($fileArrays as $key => $value) {
            $toolsString = '';
            $sharedString = '';
            if (is_file($value['path'])) {
                $value['id'] == -1 ? $identifier = $value['path'] : ($identifier = $value['id']);
                //The file/directory identifier will be the id, if the entity has a database representation, or the file path otherwise
                $value = new EfrontFile($value);
                //Restore file/directory representation, so we can use its methods
                $link = $url . '&view=' . urlencode($identifier);
                foreach ($extraFileTools as $tool) {
                    //$toolsString .= '<a href = "javascript:void(0)"><img src = "'.$tool['image'].'" alt = "'.$tool['title'].'" title = "'.$tool['title'].'" border = "0" onclick = "'.$tool['action'].'(this, \''.urlencode($identifier).'\')"  /></a>&nbsp;';
                    $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a>&nbsp;';
                }
                if (($value['extension'] == 'zip' || $value['extension'] == 'gz') && $options['zip']) {
                    $toolsString .= '<a href = "javascript:void(0)"><img src = "images/16x16/uncompress.png" alt = "' . _UNCOMPRESS . '" title = "' . _UNCOMPRESS . '" border = "0" onclick = "uncompressFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"  /></a>&nbsp;';
                }
                if ($options['download']) {
                    $toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a>&nbsp;';
                }
                if ($_SESSION['s_lessons_ID'] && $options['share']) {
                    $sharedString = '
	                    	<img class = "ajaxHandle" src = "images/16x16/trafficlight_green.png" alt = "' . _UNSHARE . '" title = "' . _UNSHARE . '" onclick = "unshareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" style = "' . (!$value['shared'] ? 'display:none' : null) . '" />
	                    	<img class = "ajaxHandle" src = "images/16x16/trafficlight_red.png"   alt = "' . _SHARE . '"   title = "' . _SHARE . '"   onclick = "shareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"   style = "' . ($value['shared'] ? 'display:none' : null) . '" />';
                }
                if ($options['metadata']) {
                    $toolsString .= '<a href = "' . $url . '&popup=1&display_metadata=' . urlencode($identifier) . '" target = "POPUP_FRAME"><img src = "images/16x16/information.png" alt = "' . _METADATA . '" title = "' . _METADATA . '" onclick = "eF_js_showDivPopup(event, \'' . _METADATA . '\', 2)" border = "0"/></a>&nbsp;';
                }
                if ($options['edit'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins)) && isset($value['users_LOGIN']) || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                }
                if ($options['delete'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins) || $value['users_LOGIN'] == "") || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}"/></a>&nbsp;';
                }
            } else {
                if (is_dir($value['path'])) {
                    $identifier = $value['path'];
                    $value = new EfrontDirectory($value['path']);
                    $link = $url . '&view_dir=' . urlencode($identifier);
                    foreach ($extraDirectoryTools as $tool) {
                        $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"  /></a>&nbsp;';
                    }
                    if ($options['edit']) {
                        $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                    }
                    if ($options['delete']) {
                        $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFolder(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}" />&nbsp;';
                    }
                }
            }
            $filesCode .= '<tr class = "defaultRowHeight ' . (fmod($i++, 2) ? 'oddRowColor' : 'evenRowColor') . '">';
            if ($options['show_type']) {
                $filesCode .= '<td class = "centerAlign"><span style = "display:none">' . (isset($value['extension']) ? $value['extension'] : '') . '</span>';
                if ($value['type'] == 'file') {
                    if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "html") !== false || strpos($value['mime_type'], "video") !== false || strpos($value['mime_type'], "flash") !== false) {
                        $filesCode .= '<a href = "javascript:void(0);" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');$(\'preview_frame\').src = \'' . $link . '\';" ><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a></td>';
                    } else {
                        $filesCode .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a>';
                    }
                } else {
                    isset($value['mime_type']) ? $mimeType = $value['mime_type'] : ($mimeType = '');
                    $filesCode .= '<img src = "' . $value->getTypeImage() . '" alt = "' . $mimeType . '" title = "' . $mimeType . '" border = "0"/></td>';
                }
            }
            if ($options['show_name']) {
                $filesCode .= '<td><span id = "span_' . urlencode($identifier) . '" style = "display:none;">' . urlencode($identifier) . '</span>';
                if ($value['type'] == 'file') {
                    if ($show_tooltip) {
                        $filesCode .= $value->toHTMLTooltipLink($link, true, $tableId);
                    } else {
                        if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "flash") !== false || strpos($value['mime_type'], "video") !== false) {
                            $filesCode .= '<a href = "' . $link . '" target = "PREVIEW_FRAME" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');">' . $value['name'] . '</a>';
                        } else {
                            $filesCode .= '<a target = "PREVIEW_FRAME" href = "' . $url . '&download=' . urlencode($identifier) . '">' . $value['name'] . '</a>';
                        }
                    }
                } else {
                    $filesCode .= '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($identifier) . '\');">' . $value['name'] . '</a>';
                }
                $filesCode .= '<span id = "edit_' . urlencode($identifier) . '" style = "display:none"><input type = "text" value = "' . $value['name'] . '" onkeypress = "if (event.which == 13 || event.keyCode == 13) {Element.extend(this).next().down().onclick(); return false;}"/>&nbsp;<a href = "javascript:void(0)"><img id = "editImage_' . urlencode($identifier) . '"src = "images/16x16/success.png" style = "vertical-align:middle" onclick = "editFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML, Element.extend(this).up().previous().value, \'' . $value['type'] . '\',\'' . eF_addslashes($value['name']) . '\')" border = "0"></a></span></td>';
            }
            $extraColumnsString = '';
            foreach ($extraColumns as $column) {
                $extraColumnsString = '<td class = "centerAlign">' . $value[$column] . '</td>';
            }
            $filesCode .= '' . ($options['show_size'] ? '<td>' . ($value['type'] == 'file' ? $value['size'] . ' ' . _KB : '') . '</td>' : '') . '
                        		' . ($options['show_date'] ? '<td>' . formatTimestamp($value['timestamp'], 'time_nosec') . '</td>' : '') . '
                        		' . $extraColumnsString . '
                        		' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . $sharedString . '</td>' : '') . '
                        		' . ($options['show_tools'] ? '<td class = "centerAlign">' . $toolsString . '</td>' : '') . '
	                        		' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . ($value['type'] == 'file' ? '<input type = "checkbox" id = "' . $identifier . '" value = "' . $identifier . '" />' : '') . '</td>' : '') . '
                        	</tr>';
        }
        $massOperationsCode = '';
        if ($size) {
            $filesCode .= '
        				</table>';
            if ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share']) {
                $massOperationsCode = '
            			<div class = "horizontalSeparatorAbove">
            				<span style = "vertical-align:middle">' . _WITHSELECTEDFILES . ':</span>
            				' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_green.png" title = "' . _SHARESELECTED . '" alt = "' . _SHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "shareSelected()"></a><a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_red.png" title = "' . _UNSHARESELECTED . '" alt = "' . _UNSHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "unshareSelected()"></a>' : '');
                if ($options['copy']) {
                    $massOperationsCode .= '
                			<form name = "copy_files_form" id = "copy_files_form" method = "post" style = "display:none;"><input type = "hidden" name = "copy_current_directory" id = "copy_current_directory"><input type = "hidden" name = "copy_files" id = "copy_files" value = "" /></form>
							<img class = "ajaxHandle" src = "images/16x16/copy.png" title = "' . _COPYSELECTED . '" alt = "' . _COPYSELECTED . '" onclick = "copyFiles(this);">
                            <img style = "display:none" class = "ajaxHandle" src = "images/16x16/paste.png" title = "' . _PASTESELECTED . '" alt = "' . _PASTESELECTED . '" onclick = "pasteFiles(this, \'' . $tableId . '\');">&nbsp;';
                }
                $massOperationsCode .= ($options['delete'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/error_delete.png" title = "' . _DELETESELECTED . '" alt = "' . _DELETESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) deleteSelected()"></a>' : '') . '
            			</div>';
            }
        } elseif (!isset($parentDir)) {
            //Don't display 'no data found' if in subdirectory, because it doesn't show up well with the .. (up one level)
            $filesCode .= '
            				<tr class = "oddRowColor defaultRowHeight"><td colspan = "100%" class = "emptyCategory">' . _NODATAFOUND . '</td></tr>
        				</table>';
        }
        $str = '
        	<div class = "headerTools">';
        if ($options['upload']) {
            $str .= '
        		<span>
            		<img src = "images/16x16/add.png" alt = "' . _UPLOADFILE . '" title = "' . _UPLOADFILE . '"/>
        			<a href = "javascript:void(0)" onclick = "$(\'url_upload\').value = \'\';$$(\'input\').each(function(s)  {if (s.type == \'file\') s.value = \'\'});$(\'upload_current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _UPLOADFILE . '\', 0, \'upload_file_table_' . $tableId . '\')">' . _UPLOADFILE . '</a>&nbsp;
        		</span>';
        }
        if ($options['create_folder']) {
            $str .= '
        		<span>
        			<img src = "images/16x16/folder_add.png" alt = "' . _CREATEFOLDER . '" title = "' . _CREATEFOLDER . '">
        			<a href = "javascript:void(0)" onclick = "$(\'current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _CREATEFOLDER . '\', 0, \'create_directory_table_' . $tableId . '\')">' . _CREATEFOLDER . '</a>&nbsp;
        		</span>';
        }
        foreach ($extraHeaderOptions as $option) {
            $str .= '
            	<span>
	        		<img src = "' . $option['image'] . '" alt = "' . $option['title'] . '" title = "' . $option['title'] . '">
    	    		<a href = "' . (isset($option['href']) ? $option['href'] : 'javascript:void(0)') . '" onclick = "' . $option['action'] . '">' . $option['title'] . '</a>&nbsp;
    	    	</span>';
        }
        $str .= '
        	</div>

        	<table style = "width:100%">
        		<tr><td>
<!--ajax:' . $tableId . '-->
        				' . $filesCode . '
<!--/ajax:' . $tableId . '-->
						' . $massOperationsCode . '
        			</td></tr>
        	</table>
        	<script>
        	var url = "' . $url . '";
        	var tableId = "' . $tableId . '";
        	</script>
        	<div id = "upload_file_table_' . $tableId . '" 	   style = "display:none;" class = "filemanagerBlock">' . $uploadFormString . '</div>
        	<div id = "create_directory_table_' . $tableId . '" style = "display:none;" class = "filemanagerBlock">' . $createFolderString . '</div>

        	<div id = "preview_table_' . $tableId . '" style = "height:100%;display:none" class = "filemanagerBlock">
                <iframe name = "PREVIEW_FRAME" id = "preview_frame" src = "about:blank" style = "border-width:0px;width:100%;height:400px;padding:0px 0px 0px 0px">Sorry, but your browser needs to support iframes to see this</iframe>
            </div>';
        /*
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $uploadFormString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "upload_file_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._UPLOADFILE.'" data=$T_BLOCK_DATA image="32x32/import.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $createFolderString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "create_directory_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._CREATEFOLDER.'" data=$T_BLOCK_DATA image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "preview_table_'.$tableId.'" style = "display:none">{eF_template_printBlock title="'._PREVIEW.'" data="<iframe name = \"PREVIEW_FRAME\" id = \"preview_frame\" src = \"about:blank\" style = \"border-width:0px;width:100%;height:100%;padding:0px\">Sorry, but your browser needs to support iframes to see this</iframe>" image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
        */
        return $str;
    }