Jump to content

Editor auto-embedding - Know which area you're at


Martin A.

Recommended Posts

Posted

While working on two auto-embedding plugins, I noticed there's no way to know which page/area/controller you're at when processing the embed, which means you could fill a signature with Youtube videos, or Google Docs (which is what I'm working on right now).

You can't use \IPS\Text\Parser::$area, as that isn't set. And since the embedding is handled trough a AJAX call, you can't really look at \IPS\Request either. So right now there is no way (that I can see) to limit the usage of the auto embedding.

I guess you'll know the editorLocation when "validateLink" is called in CKEDITOR.plugins.ipsautolink, so why not pass it along, and at least let us 3rd party devs use it.

 

What I specifically need is for Google Docs to not parse in signatures. And another plugin I need to put in a spoiler when posted in topic, but not when it's in a profile field. If there is way to do that now, I'd like to know. 

 

Thanks.

Posted

You can use the dispatcher class to get what application, module, and controller that is currently being used.

  • \IPS\Dispatcher::i()->application returns an application object
  • \IPS\Dispatcher::i()->module returns an module object
  • \IPS\Dispatcher::i()->controller simply returns the controller

Hope that helps!

 

Posted

i don't know if you have already check the header... this for example:

$_SERVER['HTTP_REFERER']
this combined with \IPS\Http\Url::internal could permise you to have control to area if I not wrong
$_SERVER['HTTP_X_REQUESTED_WITH']

+1

I guess you'll know the editorLocation when "validateLink" is called in CKEDITOR.plugins.ipsautolink, so why not pass it along, and at least let us 3rd party devs use it.

Posted

$area could be obtained by "extension" propriety defined on \IPS\Helpers\Form\Editor(...)->extension but on validateLink you could get the istance of editor?

Posted
4 hours ago, BomAle said:

i don't know if you have already check the header... this for example:


$_SERVER['HTTP_REFERER']
this combined with \IPS\Http\Url::internal could permise you to have control to area if I not wrong
$_SERVER['HTTP_X_REQUESTED_WITH']

+1

 

That is not a bad suggestion. Didn't know HTTP_REFERER was carried over on an AJAX request. Although you're not getting the true $area it's coming from, at least you know if it's a topic or not.

 

Posted

That actually solved it, @BomAle, thanks!

But that opened another can of worms. If the embedded iframe is really big, core.front.core.autoSizeIframe is causing the editor to snap back to the top when trying to scroll past it. Sometimes this is affecting the entire page too, making it impossible to scroll down to the "Save" button.

http://screencast.com/t/UvF8b6o2pW8l

Here's the HTML for it, after the link is pasted

<iframe src="http://localhost/?app=core&amp;module=system&amp;controller=embed&amp;url=https%3A%2F%2Flighterpack.com%2Fr%2Fbl37jr" data-controller="core.front.core.autoSizeIframe" scrolling="no" style="height: 2592px; overflow: hidden;"></iframe>

That's coming from this, which is the stock iframe template.

return \IPS\Theme::i()->getTemplate( 'embed', 'core', 'global' )->iframe( (string) \IPS\Http\Url::internal( 'app=core&module=system&controller=embed', 'front' )->setQueryString( 'url', (string) $url ) );

Once it's saved, everything's normal, and the iframe HTML is the same.

Any ideas on this, @Rikki?

Posted

Have the IPS devs stopped reading this forums, or what? Haven't seen a reply in any of these topics from any of you in weeks.

Thought this was a forum where we could interact directly with you. Now it's just a public Contributor Chat.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...