My goal was the next: I'm using the module less. This creates a new path in file system, and makes own css files. I thought, why can't define only path, if use settings "Define css" in Editor CSS field, and could load all css file within this path.
This patch makes a new placeholder %f to filesystem. If not .css file set, try to load .css files in directory. You can define '%f/css', if you want use the aggregated css files, or using modules less the correct path is: "%f/%t/[css_path_in_your_theme]". If css file couldn't loaded, set an error message.
I try to make this all of editors, where this settings enabled, but couldn't test it now. When I checked coder, it tells some minor bug, these are corrected too.
This is the base code for tinymce:
if (isset($config['css_setting'])) {
if ($config['css_setting'] == 'theme') {
$settings['content_css'] = implode(',', wysiwyg_get_css());
}
elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
$csspath = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme(), '%f' => file_directory_path()));
if (preg_match('/.*\.css$/', $csspath)) {
$settings['content_css'] = $csspath;
}
else {
global $base_url;
$cssfiles = file_scan_directory($csspath, '.*\.css$');
if ($cssfiles) {
foreach ($cssfiles as $key) {
$filesarray[] = $base_url . '/' . $key->filename;
}
$settings['content_css'] = implode(',', $filesarray);
}
else {
if (user_access('administer filters')) {
drupal_set_message(t("The wysiwyg css path is not configured properly. Check the !settings_url settings page!", array('!settings_url' => l(t('Wysiwyg profiles'), 'admin/settings/wysiwyg'))), 'error');
}
}
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | wysiwyg-css-public-files-1080066-6.patch | 7.9 KB | joelstein |
| #3 | 1080066_3_custom_path_to_css.patch | 3.15 KB | szantog |
| #1 | wysiwyg-tiny.patch | 18.64 KB | szantog |
| wysiwyg-tiny.patch | 18.64 KB | szantog |
Comments
Comment #1
szantog commenteda small correction in patch
Comment #2
twodThanks for the patch and cleanups, but let's keep coding style cleanups in separate patches to keep focus on the real changes.
I like the idea of fetching all .css files in a folder, but when implemented this way it means we have a folder scan on each page load where the editor appears. If there are more than one editor type loaded, that folder scan will also happen several times.
(The results from this function are not cached.)
Btw, you've got an extra .project file in the patch. ;)
Comment #3
szantog commentedOk, this is now without cleanup. :)
In new patch I put the main function in .module, and cached the results. Now, I'm using it only in tinymce. If you think, this is the good way, I will apply it the into the other editors.
Comment #4
szantog commentedand needs review..
Comment #5
sunWe can add %f, but please only add it to the existing replacements, without the helper function. Make sure to add it in all editor support includes that contain the replacement code currently.
Comment #6
joelstein commentedHere's a patch for D7 which adds support for the %f token and adds help text everywhere it should appear.
Comment #7
jurriaanroelofs commentedWorks great for me, +1
Allthough it hurts to see the same code repeated 10 time, maybe it could be refactored a little?