pull/7445/merge
johndoh 4 years ago committed by GitHub
commit 0d7c711e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,7 @@ class jqueryui extends rcube_plugin
private static $features = array();
private static $ui_theme;
private static $css_path;
private static $skin_map = array(
'larry' => 'larry',
'default' => 'elastic',
@ -45,9 +46,11 @@ class jqueryui extends rcube_plugin
foreach ($skins as $skin) {
self::$ui_theme = $ui_theme = $ui_map[$skin] ?: $skin;
self::$css_path = $this->local_skin_path('themes', $ui_theme);
if (self::asset_exists("themes/$ui_theme/jquery-ui.css")) {
$this->include_stylesheet("themes/$ui_theme/jquery-ui.css");
$css = self::$css_path . '/jquery-ui.css';
if (self::asset_exists($css)) {
$this->include_stylesheet($css);
break;
}
}
@ -104,17 +107,17 @@ class jqueryui extends rcube_plugin
$ui_theme = self::$ui_theme;
$rcube = rcube::get_instance();
$script = 'plugins/jqueryui/js/jquery.minicolors.min.js';
$css = "themes/$ui_theme/jquery.minicolors.css";
$css = self::$css_path . "/jquery.minicolors.css";
if (!self::asset_exists($css)) {
$css = "themes/larry/jquery.minicolors.css";
$css = "plugins/jqueryui/themes/larry/jquery.minicolors.css";
}
$colors_theme = $rcube->config->get('jquery_ui_colors_theme', 'default');
$config = array('theme' => $colors_theme);
$config_str = rcube_output::json_serialize($config);
$rcube->output->include_css('plugins/jqueryui/' . $css);
$rcube->output->include_css($css);
$rcube->output->include_script($script, 'head', false);
$rcube->output->add_script('$.fn.miniColors = $.fn.minicolors; $("input.colors").minicolors(' . $config_str . ')', 'docready');
$rcube->output->set_env('minicolors_config', $config);
@ -131,14 +134,14 @@ class jqueryui extends rcube_plugin
$script = 'plugins/jqueryui/js/jquery.tagedit.js';
$rcube = rcube::get_instance();
$ui_theme = self::$ui_theme;
$css = "themes/$ui_theme/tagedit.css";
$css = self::$css_path. "/tagedit.css";
if (!array_key_exists('elastic', (array) $rcube->output->skins)) {
if (!self::asset_exists($css)) {
$css = "themes/larry/tagedit.css";
$css = "plugins/jqueryui/themes/larry/tagedit.css";
}
$rcube->output->include_css('plugins/jqueryui/' . $css);
$rcube->output->include_css($css);
}
$rcube->output->include_script($script, 'head', false);
@ -150,7 +153,8 @@ class jqueryui extends rcube_plugin
protected static function asset_exists($path, $minified = true)
{
$rcube = rcube::get_instance();
$path = (strpos($path, 'plugins/') !== false ? '/' : '/plugins/jqueryui/') . $path;
return $rcube->find_asset('/plugins/jqueryui/' . $path, $minified) !== null;
return $rcube->find_asset($path, $minified) !== null;
}
}

@ -709,7 +709,10 @@ EOF;
// apply skin search escalation list to plugin directory
foreach ($this->skin_paths as $skin_path) {
// skin folder in plugin dir
$plugin_skin_paths[] = $this->app->plugins->url . $plugin . '/' . $skin_path;
// plugin folder in skin dir
$plugin_skin_paths[] = $skin_path . '/plugins/' . $plugin;
}
// prepend plugin skin paths to search list
@ -720,7 +723,7 @@ EOF;
$path = false;
foreach ($this->skin_paths as $skin_path) {
// when requesting a plugin template ignore global skin path(s)
if ($plugin && strpos($skin_path, $this->app->plugins->url) !== 0) {
if ($plugin && strpos($skin_path, $this->app->plugins->url) === false) {
continue;
}

@ -369,7 +369,7 @@ abstract class rcube_plugin
*/
private function resource_url($fn)
{
if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn)) {
if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn) && strpos($fn, $this->ID . '/') === false) {
return $this->ID . '/' . $fn;
}
else {
@ -381,21 +381,43 @@ abstract class rcube_plugin
* Provide path to the currently selected skin folder within the plugin directory
* with a fallback to the default skin folder.
*
* @return string Skin path relative to plugins directory
* @param string $extra_dir Additional directory to search in (optional)
* @param mixed $skin_name Additional skin name(s) to look for, string or array (optional)
* @return string Skin path relative to plugins directory
*/
public function local_skin_path()
public function local_skin_path($extra_dir = null, $skin_name = null)
{
$rcube = rcube::get_instance();
$skins = array_keys((array)$rcube->output->skins);
$skins = array_keys((array)$rcube->output->skins);
if (empty($skins)) {
$skins = (array) $rcube->config->get('skin');
}
$dirs = array('skins');
if (!empty($extra_dir)) {
array_unshift($dirs, $extra_dir);
}
if (!empty($skin_name)) {
$skins = (array) $skin_name;
}
foreach ($skins as $skin) {
$skin_path = 'skins/' . $skin;
if (is_dir(realpath(slashify($this->home) . $skin_path))) {
break;
foreach ($dirs as $dir) {
// skins folder in the plugins dir
$skin_path = $dir . '/' . $skin;
if (!is_dir(realpath(slashify($this->home) . $skin_path))) {
// plugins folder in the skins dir
$skin_path .= '/plugins/' . $this->ID;
if (is_dir(realpath(slashify(RCUBE_INSTALL_PATH) . $skin_path))) {
break 2;
}
}
else {
break 2;
}
}
}

@ -642,22 +642,23 @@ class rcube_plugin_api
$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' : '');
// Prefer .less files in devel_mode (assume less.js is loaded)
if ($devel_mode) {
$less = preg_replace('/\.css$/i', '.less', $fn);
if ($less != $fn && is_file("$path/plugins/$less")) {
if ($less != $fn && is_file("$dir/$less")) {
$fn = $less;
}
}
else if (!preg_match('/\.min\.css$/', $fn)) {
$min = preg_replace('/\.css$/i', '.min.css', $fn);
if (is_file("$path/plugins/$min")) {
if (is_file("$dir/$min")) {
$fn = $min;
}
}
if (!is_file("$path/plugins/$fn")) {
if (!is_file("$dir/$fn")) {
return;
}
}
@ -718,7 +719,7 @@ class rcube_plugin_api
*/
protected function resource_url($fn)
{
if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn))
if ($fn[0] != '/' && !preg_match('|^https?://|i', $fn) && strpos($fn, '/' . $this->url) === false)
return $this->url . $fn;
else
return $fn;

Loading…
Cancel
Save