tiny_file_manager-1.0.x-dev/src/Controller/PageController.php
src/Controller/PageController.php
<?php
namespace Drupal\tiny_file_manager\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
class PageController extends ControllerBase {
public function index () {
global $lang;
global $CONFIG;
error_reporting(E_ERROR);
define('FM_EMBED', true);
define('FM_SELF_URL', Url::fromRoute('tfm.admin.core.manager')->toString());
/** @var \Drupal\Core\Site\Settings $settings */
$settings = \Drupal::service("settings");
$config = \Drupal::config('tiny_file_manager.settings');
$root_path = $config->get('default_root_path') ?? $settings->get('file_public_path', 'sites/default/files');
define('FM_ROOT_URL', base_path() . $root_path);
$use_highlightjs = true;
$highlightjs_style = 'vs';
$edit_files = true;
$default_timezone = 'Etc/UTC'; // UTC
$root_url = '';
$http_host = $_SERVER['HTTP_HOST'];
$iconv_input_encoding = 'UTF-8';
$datetime_format = 'Y-m-d H:i';
// 'full', 'relative', 'host'
$path_display_mode = 'full';
$allowed_file_extensions = '';
$allowed_upload_extensions = '';
$favicon_path = '';
$exclude_items = [];
// 'google', 'microsoft' or false
$online_viewer = false;
$sticky_navbar = true;
$max_upload_size_bytes = 5000000000;
$upload_chunk_size_bytes = 2000000;
$ip_ruleset = 'OFF';
$ip_silent = true;
$ip_whitelist = [
'127.0.0.1', // local ipv4
'::1' // local ipv6
];
$ip_blacklist = [
'0.0.0.0', // non-routable meta ipv4
'::' // non-routable meta ipv6
];
global $module_path;
$module_path = \Drupal::service('extension.list.module')->getPath('tiny_file_manager');
require $module_path . '/ext/tinyfilemanager.php';
exit;
}
public function files() {
$build = [
'#type' => 'inline_template',
'#template' => '<iframe src="{{ target_url }}" frameborder="0" width="100%" scrolling="yes" style="height: 80vh;">',
'#context' => [
'target_url' => Url::fromRoute('tfm.admin.core.manager', ['target' => 'files'] ) ,
],
];
return $build;
}
}