Ejemplo n.º 1
0
function toggle($filePath)
{
    jpimport('models.sff', true);
    $model = new JoomlapackModelSff();
    $model->toggleFilter($filePath);
    return true;
}
Ejemplo n.º 2
0
 function _extraFiltersForPlugins($pluginID, $active)
 {
     // If the ID is invalid (module doesn't exist?), quit
     $allPlugins =& $this->getPlugins();
     if (!isset($allPlugins[$pluginID])) {
         return;
     }
     // Get base directory, based on front- or back-end type. RELATIVE PATHS!!!!
     if ($allPlugins[$pluginID]['frontend']) {
         $basedir = '';
     } else {
         $basedir = str_replace(JPATH_SITE . DS, '', JPATH_ADMINISTRATOR) . DS;
     }
     $basedir .= 'plugins' . DS . $allPlugins[$pluginID]['type'] . DS;
     // Use the SFF to apply inclusion/exclusion of plugin files and DEF
     // for any (optional) plugin folder
     $file1 = $basedir . $allPlugins[$pluginID]['plugin'] . '.php';
     $file2 = $basedir . $allPlugins[$pluginID]['plugin'] . '.xml';
     $pluginPath = $basedir . $allPlugins[$pluginID]['plugin'];
     jpimport('models.def', true);
     jpimport('models.sff', true);
     $defModel = new JoomlapackModelDef();
     $sffModel = new JoomlapackModelSff();
     if ($active) {
         $defModel->enableFilter($pluginPath);
         $sffModel->enableFilter($file1);
         $sffModel->enableFilter($file2);
     } else {
         $defModel->disableFilter($pluginPath);
         $sffModel->disableFilter($file1);
         $sffModel->disableFilter($file2);
     }
     // Translation files, through SFF
     if ($allPlugins[$pluginID]['frontend']) {
         // Front-end modules
         $feLangs =& $this->_getAllLanguages();
         if (count($feLangs) > 0) {
             foreach ($feLangs as $lang) {
                 $basedir = str_replace(JPATH_SITE . DS, '', $lang['basedir']) . DS . $lang['language'];
                 $file1 = $basedir . DS . $lang['language'] . '.plg_' . $allPlugins[$pluginID]['plugin'] . '.ini';
                 if ($active) {
                     $sffModel->enableFilter($file1);
                 } else {
                     $sffModel->disableFilter($file1);
                 }
             }
         }
     } else {
         // Back-end module
         $beLangs =& $this->_getAllLanguages(false);
         if (count($beLangs) > 0) {
             foreach ($beLangs as $lang) {
                 $basedir = str_replace(JPATH_SITE . DS, '', $lang['basedir']) . DS . $lang['language'];
                 $file1 = $basedir . DS . $lang['language'] . '.plg_' . $allPlugins[$pluginID]['plugin'] . '.ini';
                 if ($active) {
                     $sffModel->enableFilter($file1);
                 } else {
                     $sffModel->disableFilter($file1);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
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;
    }