? ? Pending

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
17 Oct 2022

Summary of Changes

when creating a child template it is incorrectly creating the html directory as a subdirectory of media - it should be /templates/childname/html - you can verify that by creating a template override and observing where the files are created.

the templateDetails.xml is also incorrect for the same reason

Testing Instructions

Create a child template.

Actual result BEFORE applying this Pull Request

You will see the child template has no template subdirectories and has a media/html subdirectoy
Check the templateDetails.xml and you will see

		<filename>templateDetails.xml</filename>
		<folder>html</folder>
	</files>
	<media destination="templates/site/cassiopeia" folder="media">
		<folder>js</folder>
		<folder>css</folder>
		<folder>scss</folder>
		<folder>images</folder>
	</media>

image

Expected result AFTER applying this Pull Request

You will see the child template has a template/html subdirectory and no media/html subdirectoy
Check the templateDetails.xml and you will see


  <files>
    <filename>templateDetails.xml</filename>
    <folder>html</folder>
  </files>
  <media folder="media" destination="templates/site/cassiopeia_after_pr">
    <folder>css</folder>
    <folder>js</folder>
    <folder>images</folder>
    <folder>scss</folder>
  </media>

![image](https://user-images.githubusercontent.com/1296369/196300773-4496ca7f-f5bc-4520-ab88-310941a2b310.png)

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar brianteeman brianteeman - open - 17 Oct 2022
avatar brianteeman brianteeman - change - 17 Oct 2022
Status New Pending
avatar brianteeman brianteeman - change - 17 Oct 2022
The description was changed
avatar brianteeman brianteeman - edited - 17 Oct 2022
avatar brianteeman brianteeman - change - 17 Oct 2022
The description was changed
avatar brianteeman brianteeman - edited - 17 Oct 2022
avatar brianteeman brianteeman - change - 17 Oct 2022
The description was changed
avatar brianteeman brianteeman - edited - 17 Oct 2022
avatar brianteeman brianteeman - change - 17 Oct 2022
The description was changed
avatar brianteeman brianteeman - edited - 17 Oct 2022
avatar brianteeman brianteeman - change - 17 Oct 2022
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 17 Oct 2022
Category Administration com_templates
avatar dgrammatiko
dgrammatiko - comment - 18 Oct 2022

it should be /templates/childname/html

Nope, you're wrong. As the contents of this folder SHOUD be publicly accessible the HTML folder was moved to the media folder, so once someone is hardening their security/access to their site the contents could be fetched from tinyMCE.

avatar wilsonge
wilsonge - comment - 18 Oct 2022

Nope, you're wrong. As the contents of this folder SHOUD be publicly accessible the HTML folder was moved to the media folder, so once someone is hardening their security/access to their site the contents could be fetched from tinyMCE.

The HTML folder is where the content overrides belong - they are still present in the standard installs as they are PHP Files https://github.com/joomla/joomla-cms/tree/4.2-dev/templates/cassiopeia/html

TinyMCE HTML as html files might need to be some sort of special case admittedly - but either way the majority of the files do belong in the templates dir and they indeed do not belong in the media subtree in the xml file.

avatar dgrammatiko
dgrammatiko - comment - 18 Oct 2022

The HTML folder is where the content overrides belong

True and that exposes the real problem: the implementation of this feature is subpar. Let me explain:

Eg:

tinymce.xml
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="editors" method="upgrade">
	<name>plg_editors_tinymce</name>
	<version>5.10.3</version>
	<creationDate>2005-08</creationDate>
	<author>Tiny Technologies, Inc</author>
	<authorEmail>N/A</authorEmail>
	<authorUrl>https://www.tiny.cloud</authorUrl>
	<copyright>Tiny Technologies, Inc</copyright>
	<license>LGPL</license>
	<description>PLG_TINY_XML_DESCRIPTION</description>
	<namespace path="src">Joomla\Plugin\Editors\TinyMCE</namespace>
	<files>
		<folder plugin="tinymce">forms</folder>
		<folder>src</folder>
		<folder>services</folder>
	</files>
	<media destination="editors" folder="media">
		<folder>tinymce</folder>
	</media>
	<languages>
		<language tag="en-GB">language/en-GB/plg_editors_tinymce.ini</language>
		<language tag="en-GB">language/en-GB/plg_editors_tinymce.sys.ini</language>
	</languages>
	<config>
		<fields name="params">
			<fieldset name="basic" addfieldprefix="Joomla\Plugin\Editors\TinyMCE\Field">
				<field
					name="configuration"
					type="tinymcebuilder"
					label="PLG_TINY_BUILDER"
					hiddenLabel="true"
				/>
			</fieldset>

			<fieldset name="advanced" label="PLG_TINY_FIELD_LABEL_ADVANCEDPARAMS">
				<field
					name="sets_amount"
					type="number"
					label="PLG_TINY_FIELD_NUMBER_OF_SETS_LABEL"
					filter="int"
					validate="number"
					min="3"
					default="3"
				/>

				<field
					name="html_height"
					type="text"
					label="PLG_TINY_FIELD_HTMLHEIGHT_LABEL"
					default="550px"
				/>

				<field
					name="html_width"
					type="text"
					label="PLG_TINY_FIELD_HTMLWIDTH_LABEL"
					default=""
				/>
			</fieldset>
		</fields>
	</config>
</extension>
tinymce.php
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Editors.tinymce
 *
 * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt

 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
 */

use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Session\Session;
use Joomla\Plugin\Editors\TinyMCE\PluginTraits\DisplayTrait;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * TinyMCE Editor Plugin
 *
 * @since  1.5
 */
class PlgEditorTinymce extends CMSPlugin
{
    use DisplayTrait;

    /**
     * Base path for editor files
     *
     * @since  3.5
     *
     * @deprecated 5.0
     */
    protected $_basePath = 'media/vendor/tinymce';

    /**
     * Load the language file on instantiation.
     *
     * @var    boolean
     * @since  3.1
     */
    protected $autoloadLanguage = true;

    /**
     * Loads the application object
     *
     * @var    \Joomla\CMS\Application\CMSApplication
     * @since  3.2
     */
    protected $app = null;

    /**
     * Initialises the Editor.
     *
     * @return  void
     *
     * @since   1.5
     */
    public function onInit()
    {
    }
}

class PlgEditorsTinymce extends PlgEditorTinymce
{
    /**
     * Helper function to get the active Site template style.
     *
     * @return  object
     *
     * @since   4.3.0
     */
    public function onAjaxTinymce()
    {
        // @todo collect the templates properly
        // Template
        // $templates = [];

        // if (!empty($allButtons['template'])) {
        //     // Do we have a custom content_template_path
        //     $template_path = $levelParams->get('content_template_path');
        //     $template_path = $template_path ? '/templates/' . $template_path : '/media/vendor/tinymce/templates';

        //     $filepaths = Folder::exists(JPATH_ROOT . $template_path)
        //         ? Folder::files(JPATH_ROOT . $template_path, '\.(html|txt)$', false, true)
        //         : [];

        //     foreach ($filepaths as $filepath) {
        //         $fileinfo      = pathinfo($filepath);
        //         $filename      = $fileinfo['filename'];
        //         $full_filename = $fileinfo['basename'];

        //         if ($filename === 'index') {
        //             continue;
        //         }

        //         $title       = $filename;
        //         $title_upper = strtoupper($filename);
        //         $description = ' ';

        //         if ($language->hasKey('PLG_TINY_TEMPLATE_' . $title_upper . '_TITLE')) {
        //             $title = Text::_('PLG_TINY_TEMPLATE_' . $title_upper . '_TITLE');
        //         }

        //         if ($language->hasKey('PLG_TINY_TEMPLATE_' . $title_upper . '_DESC')) {
        //             $description = Text::_('PLG_TINY_TEMPLATE_' . $title_upper . '_DESC');
        //         }

        //         $templates[] = [
        //             'title'       => $title,
        //             'description' => $description,
        //             'url'         => Uri::root(true) . $template_path . '/' . $full_filename,
        //         ];
        //     }
        // }

        header('Content-type:application/json;charset=utf-8');

        @ob_end_clean();

        if (!Session::checkToken('request') || !(Factory::getUser())->authorise('core.edit', 'com_plugins')) {
            throw new \Exception('Not Allowed');
        }

        echo (json_encode([
            [
                'title'       => 'Success',
                'description' => 'A success alert',
                'content'     => '<div class="alert alert-success">My content</div>'
            ]
        ]));

        flush();

        Factory::getApplication()->close();
    }
}

And 'templates' => Uri::base(false) . 'index.php?option=com_ajax&type=plugin&plugin=tinymce&group=editors&format=json&' . Session::getFormToken() . '=1', //$templates, @

@wilsonge what is extremely awkward is that the editors plugin due to this line

$name = 'PlgEditor' . $this->_name;
(should be $name = 'PlgEditors' . $this->_name; Editors not Editor) don't follow the API convention and thus the com_ajax events are not fired. Joomla disagrees with it's own API...

avatar brianteeman
brianteeman - comment - 18 Oct 2022

@dgrammatiko create a template override in a child template and see where the file is created

avatar dgrammatiko
dgrammatiko - comment - 18 Oct 2022

@brianteeman my bad I thought you were fixing #38911 and my comments are totally valid for that issue. If Layout overrides end up in the media folder then it's an obvious bug (will try to test later today)

I can't replicate the issue:

Screen.Recording.2022-10-18.at.11.31.10.mov

Screenshot 2022-10-18 at 11 31 55

avatar brianteeman
brianteeman - comment - 21 Oct 2022

I can't replicate the issue:

Your video shows the problem that this PR resolves

avatar toivo
toivo - comment - 24 Oct 2022

I have tested this item successfully on 5614ebf

Tested successfully in Joomla 4.2.4-dev of 24 October in Wampserver using PHP 8.1.10


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38986.

avatar toivo toivo - test_item - 24 Oct 2022 - Tested successfully
c9ce99f 1 Nov 2022 avatar brianteeman cs
avatar ReLater ReLater - test_item - 24 Dec 2022 - Tested successfully
avatar ReLater
ReLater - comment - 24 Dec 2022

I have tested this item successfully on c9ce99f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38986.

avatar viocassel viocassel - test_item - 29 Dec 2022 - Tested successfully
avatar viocassel
viocassel - comment - 29 Dec 2022

I have tested this item successfully on c9ce99f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38986.

avatar Quy Quy - change - 29 Dec 2022
Status Pending Ready to Commit
avatar Quy
Quy - comment - 29 Dec 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38986.

avatar wilsonge wilsonge - change - 29 Dec 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-12-29 18:30:12
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 29 Dec 2022
avatar wilsonge wilsonge - merge - 29 Dec 2022
avatar wilsonge
wilsonge - comment - 29 Dec 2022

Thanks!

avatar brianteeman
brianteeman - comment - 29 Dec 2022

Thanks @wilsonge

Add a Comment

Login with GitHub to post a comment