Skip to content

Commit

Permalink
force_frontend_fallback chaining
Browse files Browse the repository at this point in the history
References #148
  • Loading branch information
ophian committed Nov 19, 2014
1 parent cf500ab commit d15c4c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion include/functions_config.inc.php
Expand Up @@ -254,16 +254,30 @@ function serendipity_set_user_var($name, $val, $authorid, $copy_to_s9y = true) {
* @access public
* @param string The filename to search for in the selected template
* @param string The path selector that tells whether to return a HTTP or realpath
* @param bool Enable to include frontend template fallback chaining (used for wysiwyg Editor custom config files)
* @return string The full path+filename to the requested file
*/
function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') {
function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath', $force_frontend_fallback = false) {
global $serendipity;

$directories = array();

if (defined('IN_serendipity_admin') && $serendipity['smarty_preview'] == false) {
// Backend will always use our default backend (=defaultTemplate) as fallback.
$directories[] = isset($serendipity['template_backend']) ? $serendipity['template_backend'] . '/' : '';

if ($force_frontend_fallback) {
// If enabled, even when within the admin suite it will be possible to reference files that
// reside within a template directory.
$directories[] = $serendipity['template'] . '/';
if (isset($serendipity['template_engine']) && $serendipity['template_engine'] != null) {
$p = explode(',', $serendipity['template_engine']);
foreach($p AS $te) {
$directories[] = trim($te) . '/';
}
}
}

$directories[] = $serendipity['defaultTemplate'] .'/';
$directories[] = 'default/';
} else {
Expand Down
4 changes: 2 additions & 2 deletions include/functions_smarty.inc.php
Expand Up @@ -1035,11 +1035,11 @@ function serendipity_smarty_init($vars = array()) {
$force_internal_toolbar = true;
}
// check ckeditor custom plugin file
$ccp = serendipity_getTemplateFile('admin/ckeditor_custom_plugin.js');
$ccp = serendipity_getTemplateFile('admin/ckeditor_custom_plugin.js', 'serendipityHTTPPath', true);
$wysiwyg_customPlugin = (!empty($ccp) && !$force_internal_toolbar) ? $ccp : $serendipity['serendipityHTTPPath'] . 'htmlarea/ckeditor_s9y_plugin.js';

// check ckeditor custom config file
$ccc = serendipity_getTemplateFile('admin/ckeditor_custom_config.js');
$ccc = serendipity_getTemplateFile('admin/ckeditor_custom_config.js', 'serendipityHTTPPath', true);
$wysiwyg_customConfig = (!empty($ccc) && !$force_internal_toolbar) ? $ccc : $serendipity['serendipityHTTPPath'] . 'htmlarea/ckeditor_s9y_config.js';

}
Expand Down

5 comments on commit d15c4c8

@onli
Copy link
Member

@onli onli commented on d15c4c8 Nov 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a param to get a file from the templates directory, like the comment says, if serendipity_getTemplateFile always gets files from the template directory?

If I understand the code right, this is about getting a file in the backend from the frontend-template. This is valid, but not what the comment says.

But how this is used in the end is strange. Why would you get something from the admin-part of the frontend-template? How can this be reliable?

@garvinhicking
Copy link
Member

@garvinhicking garvinhicking commented on d15c4c8 Nov 21, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garvinhicking
Copy link
Member

@garvinhicking garvinhicking commented on d15c4c8 Nov 24, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onli
Copy link
Member

@onli onli commented on d15c4c8 Nov 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Garvin

The reason is this: Say someone creates his own frontend template and calls the directory "mytemplate", where he only puts frontend files. Now he wants to adapt the CKEditor toolbar to his liking and create a templates/mytemplate/admin/ckeditor_custom_config.js file. He uses 2k11 as default backend template.

This is the part that is strange for me. The user should just set his forked template as his admin template. Then s9y should use his files first and fall back to 2k11 for everything else. This is the part where I choose not to be involved in the ckeditor-discussion, but I don't like it at all that we introduce this uncommon behaviour just for that. It is not necessary, it should always be part of the admin template, and that function is just too central - for such a change before the RC, and for such an exception for such a small cause.

I needed days and several iterations to get the fallback chain working properly, it is just seems crazy to me to doctor with her now, toggled or not, and to introduce behaviour we already now is unstable.

@garvinhicking
Copy link
Member

@garvinhicking garvinhicking commented on d15c4c8 Nov 24, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.