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

3.7.x New TinyMCE XTD plugins don't work on frontend edit (menu / contact) #12309

Closed
andrepereiradasilva opened this issue Oct 4, 2016 · 21 comments

Comments

@andrepereiradasilva
Copy link
Contributor

andrepereiradasilva commented Oct 4, 2016

Steps to reproduce the issue

Expected result

We add a menu or contact link

Actual result

Error

System information (as much as possible)

Latest 3.7.x branch

Additional comments

This plugins only exist in 3.7.x

pinging @infograf768 @brianteeman @zero-24

@andrepereiradasilva
Copy link
Contributor Author

andrepereiradasilva commented Oct 4, 2016

just as aditional info

for the contacts i think you need the frontend component proxying to admin when view = contacts

for the menus i think you may need the component itself on the frontend proxying to the backend
See com_modules as example: https://github.com/joomla/joomla-cms/tree/staging/components/com_modules

@zero-24 zero-24 added this to the Joomla 3.7.0 milestone Oct 4, 2016
@brianteeman
Copy link
Contributor

Confirmed


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

@infograf768
Copy link
Member

release blocker


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

@infograf768
Copy link
Member

I tried to solve the issue for contacts by proxying as should.
I had to register once the admin modal though and still get this fatal error

Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/370/infograf768/administrator/components/com_contact/views/contacts/tmpl/modal.php on line 21

This is the code I used.

diff --git a/administrator/components/com_contact/views/contacts/tmpl/modal.php b/administrator/components/com_contact/views/contacts/tmpl/modal.php
index e9a8138..1e2f493 100644
--- a/administrator/components/com_contact/views/contacts/tmpl/modal.php
+++ b/administrator/components/com_contact/views/contacts/tmpl/modal.php
@@ -24,4 +24,9 @@
 $app = JFactory::getApplication();

+if ($app->isSite())
+{
+   JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
+}
+
 $function  = $app->input->getCmd('function', 'jSelectContact');
 $listOrder = $this->escape($this->state->get('list.ordering'));
diff --git a/components/com_contact/contact.php b/components/com_contact/contact.php
index a119f16..e68d2b8 100644
--- a/components/com_contact/contact.php
+++ b/components/com_contact/contact.php
@@ -12,5 +12,13 @@
 JLoader::register('ContactHelperRoute', JPATH_COMPONENT . '/helpers/route.php');

+$input = JFactory::getApplication()->input;
+
+if ($input->get('view') === 'contacts' && $input->get('layout') === 'modal')
+{
+   $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
+   require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';
+}
+
 $controller = JControllerLegacy::getInstance('Contact');
-$controller->execute(JFactory::getApplication()->input->get('task'));
+$controller->execute($input->get('task'));
 $controller->redirect();
diff --git a/components/com_contact/controller.php b/components/com_contact/controller.php
index de91f09..ac78e1d 100644
--- a/components/com_contact/controller.php
+++ b/components/com_contact/controller.php
@@ -18,4 +18,27 @@
 {
    /**
+    * Constructor.
+    *
+    * @param   array  $config  An optional associative array of configuration settings.
+    *                          Recognized key values include 'name', 'default_task', 'model_path', and
+    *                          'view_path' (this list is not meant to be comprehensive).
+    *
+    * @since   __DEPLOY_VERSION__
+    */
+   public function __construct($config = array())
+   {
+       $this->input = JFactory::getApplication()->input;
+
+       // Article frontpage Editor contact proxying:
+       if ($this->input->get('view') === 'contacts' && $this->input->get('layout') === 'modal')
+       {
+           JHtml::_('stylesheet', 'system/adminlist.css', array(), true);
+           $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
+       }
+
+       parent::__construct($config);
+   }
+
+   /**
     * Method to display a view.
     *

contactxtdfrontendissue.diff.zip

@zero-24
Copy link
Contributor

zero-24 commented Oct 5, 2016

Fatal error: Using $this when not in object context in /Applications/MAMP/htdocs/370/infograf768/administrator/components/com_contact/views/contacts/tmpl/modal.php on line 21

Strange error:

As we use the same line in com_content modal.
https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_content/views/articles/tmpl/modal.php#L29

And $this->filterForm it is defined for com_contact here: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/views/contacts/view.html.php#L78

@infograf768
Copy link
Member

Something must be missing in the code I posted above.
Both for xtd modules and xtd article, no need to load the modal as I did with
require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';

Let's hope someone can solve this.

Note: Concerning xtd menu, it is even another story as we have no com_menus in frontend...

@infograf768
Copy link
Member

infograf768 commented Oct 5, 2016

Looks like I found a possible solution...

adding in the xtd (here for contacts)

/*
         * Use the built-in element view to select the contact.
         * Currently uses blank class.
         */
        $app = JFactory::getApplication();

        if ($app->isSite())
        {
            $link = 'administrator/index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
        }
        else
        {
            $link = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
        }

I do get the modal OK and can select.

screen shot 2016-10-05 at 12 34 51

No need in this case to add require_once JPATH_COMPONENT_ADMINISTRATOR . '/views/contacts/tmpl/modal.php';

Can someone test and look if this does not have a wrong effect? (security or else)

@andrepereiradasilva
Copy link
Contributor Author

andrepereiradasilva commented Oct 5, 2016

using the administrator index.php means you need to be login admin right? Did you test that when logout of admin?

@infograf768
Copy link
Member

I have a problem in 3.7.0
As super admin, when you login in admin OR site, you are logged in both...

@andrepereiradasilva
Copy link
Contributor Author

you have shared sessions in global config set to yes right?

@brianteeman
Copy link
Contributor

Sounds like #12068 in action

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@infograf768
Copy link
Member

Ah, grrrr
shared sessions now off.
My trick does not work anymore when the user is not logged in admin. Forget it...

@infograf768
Copy link
Member

Welcome a completion of the patch proposed above...

@dgrammatiko
Copy link
Contributor

@infograf768 why don't you replicate what have been done in XTD_modules? I mean the link @andrepereiradasilva posted in the first comment

@infograf768
Copy link
Member

that is what i tried to do for contacts. obviously not enough...
concerning xtd menu we do not have anu frontend com_menus...

you did the xtd modules, you may know better


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

@dgrammatiko
Copy link
Contributor

@infograf768 your code is correct you just miss this change (add $config) in com_contact/contact.php:

$controller = JControllerLegacy::getInstance('Contact', $config);

Then it should work fine!

@infograf768
Copy link
Member

ok, will try tomorrow for contacts.

any idea for xtd menu?

@infograf768
Copy link
Member

@DGT41

Adding , $config helps. I also loaded backend language. I still get a Notice:
Notice: Undefined index: contacts in /Applications/MAMP/htdocs/370/infograf768/libraries/cms/component/router/view.php on line 86
And search tools is broken

For the xtd menus, I added in frontend an instance of com_menus with the same structure as com_modules frontend. Does not work yet.
For that one the modal displays The most recent request was denied because it contained an invalid security token. Please refresh the page and try again.

I am going to create a WIP PR to work in collaboration to solve these.


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

@infograf768
Copy link
Member

Here it is
#12320

@zero-24
Copy link
Contributor

zero-24 commented Oct 6, 2016

Closing as we have a PR by @infograf768

@zero-24 zero-24 closed this as completed Oct 6, 2016
@zero-24 zero-24 removed this from the Joomla 3.7.0 milestone Oct 6, 2016
@infograf768
Copy link
Member

a WIP one... ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants