Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] TinyMCE changes for child templates 3/3 #36011

Closed

Conversation

dgrammatiko
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

  • Copy the needed methods from HTMLHelper in the tinyMCE so that the editor.css is included correctly for the active front end template

Testing Instructions

Apply the patch in the current 4.1
Verify that the editor.css is loading as expected

Apply #35874 and then this PR
Verify that the editor.css is loading as expected

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

No debug:
Screenshot 2021-11-10 at 01 26 14

With debug enabled:
Screenshot 2021-11-10 at 01 27 30

Documentation Changes Required

No


if (!empty($found))
{
$includes[] = $found;

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PhilETaylor this method is an almost identical copy of

protected static function includeRelativeFiles($folder, $file, $relative, $detectBrowser, $detectDebug)
{
// Set debug flag
$debugMode = false;
// Detect debug mode
if ($detectDebug && JDEBUG)
{
$debugMode = true;
}
// If http is present in filename
if (strpos($file, 'http') === 0 || strpos($file, '//') === 0)
{
$includes = [$file];
}
else
{
// Extract extension and strip the file
$strip = File::stripExt($file);
$ext = File::getExt($file);
// Prepare array of files
$includes = [];
// Detect browser and compute potential files
if ($detectBrowser)
{
$navigator = Browser::getInstance();
$browser = $navigator->getBrowser();
$major = $navigator->getMajor();
$minor = $navigator->getMinor();
$minExt = '';
if (\strlen($strip) > 4 && preg_match('#\.min$#', $strip))
{
$minExt = '.min';
$strip = preg_replace('#\.min$#', '', $strip);
}
// Try to include files named filename.ext, filename_browser.ext, filename_browser_major.ext, filename_browser_major_minor.ext
// where major and minor are the browser version names
$potential = [
$strip . $minExt,
$strip . '_' . $browser . $minExt,
$strip . '_' . $browser . '_' . $major . $minExt,
$strip . '_' . $browser . '_' . $major . '_' . $minor . $minExt,
];
}
else
{
$potential = [$strip];
}
// If relative search in template directory or media directory
if ($relative)
{
$app = Factory::getApplication();
$template = $app->getTemplate(true);
$templaPath = JPATH_THEMES;
if ($template->inheritable || !empty($template->parent))
{
$client = $app->isClient('administrator') === true ? 'administrator' : 'site';
$templaPath = JPATH_ROOT . "/media/templates/$client";
}
// For each potential files
foreach ($potential as $strip)
{
$files = [];
$files[] = $strip . '.' . $ext;
/**
* Loop on 1 or 2 files and break on first found.
* Add the content of the MD5SUM file located in the same folder to url to ensure cache browser refresh
* This MD5SUM file must represent the signature of the folder content
*/
foreach ($files as $file)
{
if (!empty($template->parent))
{
$found = static::addFileToBuffer("$templaPath/$template->template/$folder/$file", $ext, $debugMode);
if (empty($found))
{
$found = static::addFileToBuffer("$templaPath/$template->parent/$folder/$file", $ext, $debugMode);
}
}
else
{
$found = static::addFileToBuffer("$templaPath/$template->template/$folder/$file", $ext, $debugMode);
}
if (!empty($found))
{
$includes[] = $found;
break;
}
else
{
// If the file contains any /: it can be in a media extension subfolder
if (strpos($file, '/'))
{
// Divide the file extracting the extension as the first part before /
list($extension, $file) = explode('/', $file, 2);
// If the file yet contains any /: it can be a plugin
if (strpos($file, '/'))
{
// Divide the file extracting the element as the first part before /
list($element, $file) = explode('/', $file, 2);
// Try to deal with plugins group in the media folder
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$element/$folder/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
// Try to deal with classical file in a media subfolder called element
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$folder/$element/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
// Try to deal with system files in the template folder
if (!empty($template->parent))
{
$found = static::addFileToBuffer("$templaPath/$template->template/$folder/system/$element/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
$found = static::addFileToBuffer("$templaPath/$template->parent/$folder/system/$element/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
else
{
// Try to deal with system files in the media folder
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$element/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
}
else
{
// Try to deal with files in the extension's media folder
$found = static::addFileToBuffer(JPATH_ROOT . "/media/$extension/$folder/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
// Try to deal with system files in the template folder
if (!empty($template->parent))
{
$found = static::addFileToBuffer("$templaPath/$template->template/$folder/system/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
$found = static::addFileToBuffer("$templaPath/$template->parent/$folder/system/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
else
{
// Try to deal with system files in the template folder
$found = static::addFileToBuffer("$templaPath/$template->template/$folder/system/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
// Try to deal with system files in the media folder
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
}
else
{
// Try to deal with system files in the media folder
$found = static::addFileToBuffer(JPATH_ROOT . "/media/system/$folder/$file", $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
}
}
}
}
else
{
// If not relative and http is not present in filename
foreach ($potential as $strip)
{
$files = [];
$files[] = $strip . '.' . $ext;
/**
* Loop on 1 or 2 files and break on first found.
* Add the content of the MD5SUM file located in the same folder to url to ensure cache browser refresh
* This MD5SUM file must represent the signature of the folder content
*/
foreach ($files as $file)
{
$path = JPATH_ROOT . "/$file";
$found = static::addFileToBuffer($path, $ext, $debugMode);
if (!empty($found))
{
$includes[] = $found;
break;
}
}
}
}
}
return $includes;
}

I just removed the parts that weren't relevant here...

@dgrammatiko dgrammatiko changed the title [4.1][alternative] TinyMCE changes for child templates 3/3 [4.1] TinyMCE changes for child templates 3/3 Nov 17, 2021
@bembelimen bembelimen added this to the Joomla 4.1 milestone Nov 25, 2021
- simplify the logic for the editor.css
- add the code from joomla#35669 for the template snippets to support files placed in the media folder (aka publically accessible)
@PhilETaylor

This comment was marked as abuse.

dgrammatiko added a commit to dgrammatiko/joomla-cms that referenced this pull request Nov 27, 2021
@dgrammatiko
Copy link
Contributor Author

This has been moved to #35998

bembelimen added a commit that referenced this pull request Nov 30, 2021
* Fix the missing installer info

* Fix the template thumb images

* Fix missing language on style view

* Update Templates.php

* Update libraries/src/Installer/Installer.php

Co-authored-by: Brian Teeman <[email protected]>

* Update build/media_source/system/images/template_thumb.svg

Co-authored-by: Brian Teeman <[email protected]>

* Update build/media_source/system/images/template_thumb.svg

Co-authored-by: Brian Teeman <[email protected]>

* Fix the thumb logic

* editor #1

* CS

* CS

* CS + fix logic

* Ensure the isMedia flag is correcly propageted

* Ooops, forgot the child creation functionality

From #35879

* CS

* Update administrator/components/com_templates/tmpl/template/default_modal_child_body.php

Co-authored-by: Brian Teeman <[email protected]>

* Update administrator/components/com_templates/tmpl/template/default_modal_child_footer.php

Co-authored-by: Brian Teeman <[email protected]>

* Fix the description for the child name

* Update administrator/components/com_templates/tmpl/template/default_media_folders.php

Co-authored-by: Brian Teeman <[email protected]>

* Update administrator/components/com_templates/tmpl/template/default_tree_media.php

Co-authored-by: Brian Teeman <[email protected]>

* Fix copy/pasting doc blocks

* Child tmpl name === parentTmplName_childName

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Brian Teeman <[email protected]>

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Brian Teeman <[email protected]>

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Brian Teeman <[email protected]>

* Update administrator/components/com_templates/src/View/Template/HtmlView.php

Co-authored-by: Brian Teeman <[email protected]>

* CS

* Update administrator/components/com_templates/src/Service/HTML/Templates.php

Co-authored-by: Quy <[email protected]>

* Update administrator/components/com_templates/src/Controller/TemplateController.php

Co-authored-by: Benjamin Trenkle <[email protected]>

* Bailout Early

* CS

* Don't throw warnings

* better conditianal

* More notices

* Fix the thumb paths

* Fix Fat FS lookups

* Fix the missing media folder for the child template

* don't echo the first slash on win OS

* .html is not in the allowed list. WOW

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/Controller/TemplateController.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/tmpl/template/default_modal_folder_body.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/tmpl/template/default_media_folders.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/tmpl/template/default.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/View/Template/HtmlView.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/Controller/TemplateController.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Phil E. Taylor <[email protected]>

* Update administrator/components/com_templates/src/Model/TemplateModel.php

Co-authored-by: Phil E. Taylor <[email protected]>

* CS, proper media folder logic

* CS

* Meh

* Paths...

* better tree entry names

* Use current user name, current date for child

* Bug, file delete

* Fix upload

* Add a visual cue for parent/child

* Add buttons to switch between list views

@bembelimen's idea

* Wrong comments

* Clean up the child method

* PHP notice, use entry dir as the starting point

* Correct icon

* Undefined $isMedia Pfff

* Update administrator/components/com_templates/src/Controller/TemplateController.php

Co-authored-by: Richard Fath <[email protected]>

* Update administrator/components/com_templates/src/Controller/TemplateController.php

Co-authored-by: Richard Fath <[email protected]>

* Merge #36011

* Remove a debug line

* Windows use / instead of \

* Winows double //

* Update administrator/language/en-GB/com_templates.ini

Co-authored-by: Brian Teeman <[email protected]>

* double //

* b->strong

* rename modatl tittle //

* Update administrator/components/com_templates/tmpl/template/default_tree_media.php

Co-authored-by: Quy <[email protected]>

* Update plugins/editors/tinymce/tinymce.php

Co-authored-by: Quy <[email protected]>

* Switch the fallback icon

This has a Creative Commons Zero v1.0 Universal (CC0) license
and it was copied from: https://iconduck.com/search?query=xcode

* Update administrator/components/com_templates/src/View/Styles/HtmlView.php

Co-authored-by: Quy <[email protected]>

* Update administrator/language/en-GB/com_templates.ini

Co-authored-by: Quy <[email protected]>

* Update plugins/editors/tinymce/tinymce.php

Co-authored-by: Quy <[email protected]>

* Update administrator/language/en-GB/com_templates.ini

Co-authored-by: Quy <[email protected]>

* tabs

* Lang failsafe

* Update administrator/components/com_templates/tmpl/template/default_folders.php

Co-authored-by: Quy <[email protected]>

Co-authored-by: Brian Teeman <[email protected]>
Co-authored-by: Quy <[email protected]>
Co-authored-by: Benjamin Trenkle <[email protected]>
Co-authored-by: Phil E. Taylor <[email protected]>
Co-authored-by: Richard Fath <[email protected]>
@dgrammatiko dgrammatiko deleted the 4.1-dev-tinyMCE-changes-2 branch April 18, 2022 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants