From 151428613873def55fe5b7ca0093af920d03f875 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 20 Apr 2024 17:22:24 +0200 Subject: [PATCH] Get rid of assets_dir, it's not needed anymore --- config/defaults.inc.php | 4 ---- program/include/rcmail.php | 5 ++--- program/include/rcmail_action.php | 18 +++--------------- program/include/rcmail_output_html.php | 16 +++------------- program/lib/Roundcube/rcube_plugin_api.php | 4 +--- 5 files changed, 9 insertions(+), 38 deletions(-) diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 40e7ef9df6..dd225a8a5e 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -872,10 +872,6 @@ // $config['assets_path'] = ''; -// While assets_path is for the browser, assets_dir informs -// PHP code about the location of asset files in filesystem -$config['assets_dir'] = ''; - // Options passed when creating Guzzle HTTP client, used to fetch remote content // For example: // [ diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 895d8f816a..ab96875bf3 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1541,8 +1541,7 @@ public function find_asset($path, $minified = true) return null; } - $assets_dir = $this->config->get('assets_dir'); - $root_path = unslashify($assets_dir ?: INSTALL_PATH) . '/'; + $root_path = unslashify(INSTALL_PATH) . '/'; $full_path = $root_path . trim($path, '/'); if (file_exists($full_path)) { @@ -1942,7 +1941,7 @@ public static function get_uids($uids = null, $mbox = null, &$is_multifolder = f } /** - * Get resource file content (with assets_dir support) + * Get resource file content * * @param string $name File name * diff --git a/program/include/rcmail_action.php b/program/include/rcmail_action.php index d1eabbfffb..0053b18364 100644 --- a/program/include/rcmail_action.php +++ b/program/include/rcmail_action.php @@ -370,7 +370,6 @@ public static function html_editor($mode = '', $editorId = null) $language = $_SESSION['language'] ?? 'en_US'; $lang_codes = [$language]; - $assets_dir = $rcmail->config->get('assets_dir') ?: INSTALL_PATH; $skin_path = $rcmail->output->get_skin_path(); if ($pos = strpos($language, '_')) { @@ -378,7 +377,7 @@ public static function html_editor($mode = '', $editorId = null) } foreach ($lang_codes as $code) { - if (file_exists("{$assets_dir}/program/js/tinymce/langs/{$code}.js")) { + if (file_exists(INSTALL_PATH . "/program/js/tinymce/langs/{$code}.js")) { $lang = $code; break; } @@ -833,7 +832,7 @@ public static function get_uids($uids = null, $mbox = null, &$is_multifolder = f } /** - * Get resource file content (with assets_dir support) + * Get resource file content * * @param string $name File name * @@ -845,18 +844,7 @@ public static function get_resource_content($name) $name = "program/resources/{$name}"; } - $assets_dir = rcmail::get_instance()->config->get('assets_dir'); - - if ($assets_dir) { - $path = slashify($assets_dir) . $name; - if (@file_exists($path)) { - $name = $path; - } - } else { - $name = INSTALL_PATH . $name; - } - - return file_get_contents($name, false); + return file_get_contents(INSTALL_PATH . $name, false); } /** diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 64292658a1..5ae5b737b9 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -109,7 +109,7 @@ protected function init($framed = false) // load and setup the skin $this->set_skin($this->config->get('skin')); - $this->set_assets_path($this->config->get('assets_path'), $this->config->get('assets_dir')); + $this->set_assets_path($this->config->get('assets_path')); if (!empty($_REQUEST['_extwin'])) { $this->set_env('extwin', 1); @@ -186,10 +186,9 @@ public function set_env($name, $value, $addtojs = true) /** * Parse and set assets path * - * @param string $path Assets path URL (relative or absolute) - * @param string $fs_dir Assets path in filesystem + * @param string $path Assets path URL (relative or absolute) */ - public function set_assets_path($path, $fs_dir = null) + public function set_assets_path($path) { // set absolute path for assets if /index.php/foo/bar url is used if (empty($path) && !empty($_SERVER['PATH_INFO'])) { @@ -225,15 +224,6 @@ public function set_assets_path($path, $fs_dir = null) } } - // set filesystem path for assets - if ($fs_dir) { - if ($fs_dir[0] != '/') { - $fs_dir = realpath(RCUBE_INSTALL_PATH . $fs_dir); - } - // ensure the path ends with a slash - $this->assets_dir = rtrim($fs_dir, '/') . '/'; - } - $this->assets_path = $path; $this->set_env('assets_path', $path); } diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php index 831f5c0ccf..49185100e4 100644 --- a/program/lib/Roundcube/rcube_plugin_api.php +++ b/program/lib/Roundcube/rcube_plugin_api.php @@ -671,9 +671,7 @@ public function include_stylesheet($fn) if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn)) { $rcube = rcube::get_instance(); $devel_mode = $rcube->config->get('devel_mode'); - $assets_dir = $rcube->config->get('assets_dir'); - $path = unslashify($assets_dir ?: RCUBE_INSTALL_PATH); - $dir = $path . (strpos($fn, 'plugins/') === false ? '/plugins' : ''); + $dir = unslashify(RCUBE_INSTALL_PATH) . (strpos($fn, 'plugins/') === false ? '/plugins' : ''); // Prefer .less files in devel_mode (assume less.js is loaded) if ($devel_mode) {