function toggleDirectories($filePath) { jpimport('models.skip', true); $model = new JoomlapackModelSkip(); $model->toggleDirectoriesFilter($filePath); return true; }
/** * 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; }