@copyright Copyright (C) 2021. All Rights Reserved. @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) .-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( \____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\MVC\Model\ListModel; use Joomla\Utilities\ArrayHelper; /** * Extensiondistributor Ajax List Model */ class ExtensiondistributorModelAjax extends ListModel { protected $app_params; public function __construct() { parent::__construct(); // get params $this->app_params = JComponentHelper::getParams('com_extensiondistributor'); } // Used in maintenance public function showdir( $dir, $folderOnly = false, $showRoot = false, $level = 0, // do not use!!! $ef = '' // do not use!!! ) { $html = ''; if ((int) $level == 0) { $dir = realpath($dir); $ef = ($showRoot ? realpath($dir.'/..').'/' : $dir.'/'); } if (!file_exists($dir)) return ''; if ($showRoot && (int) $level == 0) { $html = ''; } else { $list = scandir($dir); if (is_array($list)) { $list = array_diff($list, array('.', '..')); if ($list) { $folders = array(); $files = array(); foreach ($list as $name) { if (is_dir($dir . DIRECTORY_SEPARATOR . $name)) { $folders[] = $name; } else { $files[] = $name; } } if (!($folderOnly && !$folders) || !(!$folders || !$files)) { $html .= ''; } sort($folders); sort($files); foreach ($folders as $name) { $fpath = $dir.'/'.$name; $subdir = $this->showdir($fpath, $folderOnly, $showRoot, $level + 1, $ef); $fpath = str_replace('\\', '/', str_replace($ef, '', $fpath)); $html .= '
  • ' . ($subdir ? '' : '') . '' . $name . '' . $subdir . '
  • '; } if (!$folderOnly) foreach ($files as $name) { $fpath = $dir.'/'.$name; $fpath = str_replace('\\', '/', str_replace($ef, '', $fpath)); $ext = substr(strrchr($name, '.'), 1); $html .= '
  • ' . $name . '
  • '; } if (!($folderOnly && !$folders) || !(!$folders || !$files)) { $html .= ''; } unset($folders, $files, $fpath, $ext); } } } return $html; } }