Beispiel #1
0
    /**
     * Returns the HTML for the file pane of the specified folder
     *
     * @param string $folder The folder for which to return a file pane
     */
    function getFilePane($folder)
    {
        // Get the "backup method"
        jpimport('models.registry', true);
        $profile =& JoomlapackModelRegistry::getInstance();
        $method = $profile->get('backupMethod');
        $folder = trim($folder, DS);
        $folder = trim($folder, '/');
        // Load the model
        if (!class_exists('JoomlapackModelSff')) {
            jpimport('models.sff', true);
        }
        $model = new JoomlapackModelSff();
        // Import Joomla! folder utility functions
        jimport('joomla.filesystem.folder');
        // Construct the fully qualified pathname
        $path = JPATH_ROOT . DS . $folder;
        //$path = JFolder::makeSafe($path);
        if (!JFolder::exists($path)) {
            return "<p>" . JText::_('SFF_ERROR_INVALIDFOLDER');
        }
        // Get the subfolders of this folder
        $files = JFolder::files($path);
        // Initialize output
        $txt_files = JText::_('SFF_LABEL_FILES');
        $out = <<<ENDHTML
<table class="adminlist">
\t<thead>
\t\t<tr>
\t\t\t<th>{$txt_files}</th>
\t\t</tr>
\t</thead>
\t<tbody>
ENDHTML;
        // Do we have files?
        if (empty($files)) {
            // No, warn user
            $out .= "<p>" . JText::_('SFF_ERROR_NOFILES') . '</p>';
        } else {
            $urlbase = JURI::base() . '/index.php?option=com_joomlapack&view=sff&folder=' . htmlentities($folder) . '&task=toggle&file=';
            foreach ($files as $file) {
                $myPath = trim($folder . DS . $file, DS);
                if ($method == 'ajax') {
                    $href = 'javascript:toggle(\'' . addslashes($myPath) . '\');';
                } else {
                    $href = $urlbase . htmlentities($file);
                }
                $htmlFile = htmlentities($file);
                // Make excluded files red and bold
                if ($model->isSetFor($myPath)) {
                    $style = 'style="color:red; font-weight: bold; text-decoration: none"';
                } else {
                    $style = 'style="text-decoration: none"';
                }
                $out .= <<<ENDHTML
\t\t<tr>
\t\t\t<td>
\t\t\t\t<a href="{$href}" {$style}>{$htmlFile}</a>
\t\t\t</td>
\t\t</tr>
ENDHTML;
            }
        }
        $out .= <<<ENDHTML
\t</tbody>
</table>
ENDHTML;
        return $out;
    }