Skip to content

Commit

Permalink
Get rid of assets_dir, it's not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Apr 20, 2024
1 parent 068c6ec commit 1514286
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 38 deletions.
4 changes: 0 additions & 4 deletions config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,6 @@
// </FilesMatch>
$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:
// [
Expand Down
5 changes: 2 additions & 3 deletions program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
*
Expand Down
18 changes: 3 additions & 15 deletions program/include/rcmail_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,14 @@ 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, '_')) {
$lang_codes[] = substr($language, 0, $pos);
}

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;
}
Expand Down Expand Up @@ -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
*
Expand All @@ -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);
}

/**
Expand Down
16 changes: 3 additions & 13 deletions program/include/rcmail_output_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions program/lib/Roundcube/rcube_plugin_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1514286

Please sign in to comment.