function toggle($filePath)
{
    jpimport('models.def', true);
    $model = new JoomlapackModelDef();
    $model->toggleFilter($filePath);
    return true;
}
Example #2
0
    /**
     * Returns the HTML for the folder pane of the specified folder
     *
     * @param string $folder The folder for which to return a folder pane
     */
    function getFolderPane($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('JoomlapackModelSkip')) {
            jpimport('models.skip', true);
        }
        $model = new JoomlapackModelSkip();
        // Additionally load DEF model
        if (!class_exists('JoomlapackModelDef')) {
            jpimport('models.def', true);
        }
        $modelDEF = new JoomlapackModelDef();
        // Import Joomla! folder utility functions
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.path');
        // Construct the fully qualified pathname
        $folder = trim($folder, DS);
        $folder = trim($folder, '/');
        $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
        $folders = JFolder::folders($path, '.', false, false, array('.', '..'));
        // Calculate parent folder
        $thisPath = JPath::clean($path);
        // Cleanup current path
        $thisPath = rtrim($thisPath, DS);
        // Trim trailing slashes
        $lastDS = strrpos($thisPath, DS);
        // Find last occurence of DS
        $upPath = substr($thisPath, 0, $lastDS);
        // Copy the part up to the previous directory
        $aboveRoot = strlen($upPath) < strlen(JPath::clean(JPATH_ROOT));
        // We shouldn't go ABOVE the root!
        $upPath = str_replace(JPath::clean(JPATH_ROOT), DS, $upPath);
        $upPath = DS . trim($upPath, DS);
        // Initialize output
        $txt_folders = JText::_('DEF_LABEL_SUBDIRECTORIES');
        $out = <<<ENDHTML
<table class="adminlist">
\t<thead>
\t\t<tr>
\t\t\t<th>{$txt_folders}</th>
\t\t</tr>
\t</thead>
\t<tbody>
ENDHTML;
        // Add a parent folder entry if it's not the root folder
        if (!$aboveRoot) {
            $urlbase = JURI::base() . '/index.php?option=com_joomlapack&view=skip&folder=';
            if ($method == 'ajax') {
                $href = 'javascript:folderpane(\'' . addslashes($upPath) . '\');';
            } else {
                $href = $urlbase . htmlentities($upPath);
            }
            $htmlDir = JText::_('DEF_LABEL_GOUP');
            $out .= <<<ENDHTML
\t\t<tr>
\t\t\t<td>
\t\t\t\t<a href="{$href}">{$htmlDir}</a>
\t\t\t</td>
\t\t</tr>
ENDHTML;
        }
        // Do we have files?
        if (empty($folders)) {
            // No, warn user
            $out .= "<tr><td><p>" . JText::_('DEF_ERROR_EMPTYDIR') . '</p></td></tr>';
        } else {
            $imageURL = JURI::base() . '/components/com_joomlapack/assets/images/arrow_small.png';
            $go_txt1 = JText::_('DCS_TOGGLE_FILES');
            $go_txt2 = JText::_('DCS_TOGGLE_DIRS');
            $urlbase1 = JURI::base() . '/index.php?option=com_joomlapack&view=skip&folder=' . htmlentities($folder) . '&task=togglefiles&item=';
            $urlbase2 = JURI::base() . '/index.php?option=com_joomlapack&view=skip&folder=' . htmlentities($folder) . '&task=toggledirs&item=';
            foreach ($folders as $thisEntry) {
                $myPath = trim($folder . DS . $thisEntry, DS);
                if ($method == 'ajax') {
                    $href1 = 'javascript:toggleFiles(\'' . addslashes($myPath) . '\');';
                    $href2 = 'javascript:toggleDirectories(\'' . addslashes($myPath) . '\');';
                    $href3 = 'javascript:folderpane(\'' . addslashes($myPath) . '\');';
                } else {
                    $href1 = $urlbase1 . htmlentities($thisEntry);
                    $href2 = $urlbase2 . htmlentities($thisEntry);
                    $href3 = JURI::base() . '/index.php?option=com_joomlapack&view=skip&folder=' . htmlentities($myPath);
                }
                $htmlFolder = htmlentities($thisEntry);
                $out .= <<<ENDHTML
\t\t<tr>
\t\t\t<td>
ENDHTML;
                $excluded = $modelDEF->isSetFor($myPath);
                // Create Skip Files link grayed if the directory is DEF-excluded
                if ($excluded) {
                    $out .= <<<ENDHTML
\t\t\t\t<span style="color: gray; font-style: italic;">[ {$go_txt1}<img src="{$imageURL}" width="10" height="10" border="0"> ]</span>
ENDHTML;
                } elseif ($model->isFilesSetFor($myPath)) {
                    $out .= <<<ENDHTML
\t\t\t\t<a href="{$href1}" style="color: green;">[ {$go_txt1}<img src="{$imageURL}" width="10" height="10" border="0"> ]</a>
ENDHTML;
                } else {
                    // Create Skip Files link normal if you can enable it
                    $out .= <<<ENDHTML
\t\t\t\t<a href="{$href1}">[ {$go_txt1}<img src="{$imageURL}" width="10" height="10" border="0"> ]</a>
ENDHTML;
                }
                // Make DEF-excluded folders gray
                if ($excluded) {
                    $style = 'style="color:gray; font-weight: bold; text-decoration: none"';
                    $out .= <<<ENDHTML
\t\t\t\t<span style="color: gray; font-style: italic;">[ {$go_txt2}<img src="{$imageURL}" width="10" height="10" border="0"> ]</span>
\t\t\t\t<span {$style}>{$htmlFolder}</span>
ENDHTML;
                } elseif (!$excluded && $model->isDirectoriesSetFor($myPath)) {
                    $style = 'style="color:red; font-weight: bold; text-decoration: none"';
                    $out .= <<<ENDHTML
\t\t\t\t<a href="{$href2}" style="color: green;">[ {$go_txt2}<img src="{$imageURL}" width="10" height="10" border="0"> ]</a>
\t\t\t\t<span {$style}>{$htmlFolder}</span>
ENDHTML;
                } else {
                    $style = 'style="text-decoration: none"';
                    $out .= <<<ENDHTML
\t\t\t\t<a href="{$href2}">[ {$go_txt2}<img src="{$imageURL}" width="10" height="10" border="0"> ]</a>
\t\t\t\t<a href="{$href3}" {$style}>{$htmlFolder}</a>
ENDHTML;
                }
                $out .= <<<ENDHTML
\t\t\t</td>
\t\t</tr>
ENDHTML;
            }
        }
        $out .= <<<ENDHTML
\t</tbody>
</table>
ENDHTML;
        return $out;
    }
Example #3
0
 function _extraFiltersForTemplates($templateID, $active)
 {
     // If the template code is invalid (template doesn't exist?), quit
     $allTemplates =& $this->getTemplates();
     if (!isset($allTemplates[$templateID])) {
         return;
     }
     $tempPath = str_replace(JPATH_SITE . DS, '', $allTemplates[$templateID]['basedir']) . DS . $allTemplates[$templateID]['template'];
     // Use the DEF to apply inclusion/exclusion of template directory
     jpimport('models.def', true);
     $defModel = new JoomlapackModelDef();
     if ($active) {
         $defModel->enableFilter($tempPath);
     } else {
         $defModel->disableFilter($tempPath);
     }
 }
Example #4
0
    /**
     * Returns the HTML for the folder pane of the specified folder
     *
     * @param string $folder The folder for which to return a folder pane
     */
    function getFolderPane($folder)
    {
        // Get the "backup method"
        jpimport('models.registry', true);
        $profile =& JoomlapackModelRegistry::getInstance();
        $method = $profile->get('backupMethod');
        // Import Joomla! folder utility functions
        jimport('joomla.filesystem.path');
        jimport('joomla.filesystem.folder');
        // Construct the fully qualified pathname
        $folder = trim($folder, DS);
        $folder = trim($folder, '/');
        $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
        $folders = JFolder::folders($path, '.', false, false, array('.', '..'));
        // Calculate parent folder
        $thisPath = JPath::clean($path);
        // Cleanup current path
        $thisPath = rtrim($thisPath, DS);
        // Trim trailing slashes
        $lastDS = strrpos($thisPath, DS);
        // Find last occurence of DS
        $upPath = substr($thisPath, 0, $lastDS);
        // Copy the part up to the previous directory
        $aboveRoot = strlen($upPath) < strlen(JPath::clean(JPATH_ROOT));
        // We shouldn't go ABOVE the root!
        $upPath = str_replace(JPath::clean(JPATH_ROOT), DS, $upPath);
        $upPath = DS . trim($upPath, DS);
        // Initialize output
        $txt_folder = JText::_('SFF_LABEL_SUBDIRECTORIES');
        $out = <<<ENDHTML
<table class="adminlist">
\t<thead>
\t\t<tr>
\t\t\t<th>{$txt_folder}</th>
\t\t</tr>
\t</thead>
\t<tbody>
ENDHTML;
        // Add a parent folder entry if it's not the root folder
        if (!$aboveRoot) {
            $urlbase = JURI::base() . '/index.php?option=com_joomlapack&view=sff&folder=';
            if ($method == 'ajax') {
                $href = 'javascript:folderpane(\'' . addslashes($upPath) . '\');';
            } else {
                $href = $urlbase . htmlentities($upPath);
            }
            $htmlDir = JText::_('SFF_LABEL_GOUP');
            $out .= <<<ENDHTML
\t\t<tr>
\t\t\t<td>
\t\t\t\t<a href="{$href}">{$htmlDir}</a>
\t\t\t</td>
\t\t</tr>
ENDHTML;
        }
        // Do we have subfolders?
        if (empty($folders) && $aboveRoot) {
            // No, warn user
            $out .= "<p>" . JText::_('SFF_ERROR_NOSUBDIRECTORIES') . '</p>';
        } elseif (!empty($folders)) {
            jpimport('models.def', true);
            $defmodel = new JoomlapackModelDef();
            $urlbase = JURI::base() . '/index.php?option=com_joomlapack&view=sff&folder=';
            foreach ($folders as $dir) {
                if ($method == 'ajax') {
                    $href = 'javascript:folderpane(\'' . addslashes($folder . DS . $dir) . '\');';
                } else {
                    $href = $urlbase . htmlentities($folder . DS . $dir);
                }
                $htmlDir = htmlentities($dir);
                $style = '';
                $htmlExcluded = '';
                $myPath = trim($folder . DS . $dir, DS);
                if ($defmodel->isSetFor($myPath)) {
                    $style = 'style="color: #333333; font-style: italic"';
                    $href = '#';
                    $htmlExcluded = '<span style="color: #663333; font-style: normal">' . JText::_('SFF_LABEL_EXCLUDED') . '</span>';
                    $html = '<span ' . $style . '>' . $htmlDir . ' ' . $htmlExcluded . '</span>';
                } else {
                    $html = '<a href="' . $href . '" ' . $style . '>' . $htmlDir . ' ' . $htmlExcluded . '</a>';
                }
                $out .= <<<ENDHTML
\t\t<tr>
\t\t\t<td>
\t\t\t\t{$html}
\t\t\t</td>
\t\t</tr>
ENDHTML;
            }
        }
        $out .= <<<ENDHTML
\t</tbody>
</table>
ENDHTML;
        return $out;
    }