Skip to content

Commit

Permalink
3.6.3: Allow author to use xtd-editors (joomla#12353)
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 authored and rdeutz committed Oct 11, 2016
1 parent 3e2ac1b commit 8acabc8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 67 deletions.
24 changes: 1 addition & 23 deletions components/com_content/content.php
Expand Up @@ -12,28 +12,6 @@
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
JLoader::register('ContentHelperQuery', JPATH_SITE . '/components/com_content/helpers/query.php');

$input = JFactory::getApplication()->input;
$user = JFactory::getUser();

if ($input->get('view') === 'article' && $input->get('layout') === 'pagebreak')
{
if (!$user->authorise('core.edit', 'com_content'))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

return;
}
}
elseif ($input->get('view') === 'articles' && $input->get('layout') === 'modal')
{
if (!$user->authorise('core.edit', 'com_content'))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

return;
}
}

$controller = JControllerLegacy::getInstance('Content');
$controller->execute($input->get('task'));
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
57 changes: 32 additions & 25 deletions plugins/editors-xtd/article/article.php
Expand Up @@ -39,36 +39,43 @@ public function onDisplay($name)
* jSelectArticle creates the link tag, sends it to the editor,
* and closes the select frame.
*/
$js = "
function jSelectArticle(id, title, catid, object, link, lang)
$user = JFactory::getUser();

if ($user->authorise('core.create', 'com_content')
|| $user->authorise('core.edit', 'com_content')
|| $user->authorise('core.edit.own', 'com_content'))
{
var hreflang = '';
if (lang !== '')
$js = "
function jSelectArticle(id, title, catid, object, link, lang)
{
var hreflang = ' hreflang = \"' + lang + '\"';
}
var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
jInsertEditorText(tag, '" . $name . "');
jModalClose();
}";
var hreflang = '';
if (lang !== '')
{
var hreflang = ' hreflang = \"' + lang + '\"';
}
var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
jInsertEditorText(tag, '" . $name . "');
jModalClose();
}";

$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);

/*
* Use the built-in element view to select the article.
* Currently uses blank class.
*/
$link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
/*
* Use the built-in element view to select the article.
* Currently uses blank class.
*/
$link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";

return $button;
return $button;
}
}
}
27 changes: 17 additions & 10 deletions plugins/editors-xtd/module/module.php
Expand Up @@ -38,17 +38,24 @@ public function onDisplay($name)
* Use the built-in element view to select the module.
* Currently uses blank class.
*/
$link = 'index.php?option=com_modules&amp;view=modules&amp;layout=modal&amp;tmpl=component&amp;editor='
. $name . '&amp;' . JSession::getFormToken() . '=1';
$user = JFactory::getUser();

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_MODULE_BUTTON_MODULE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
if ($user->authorise('core.create', 'com_content')
|| $user->authorise('core.edit', 'com_content')
|| $user->authorise('core.edit.own', 'com_content'))
{
$link = 'index.php?option=com_modules&amp;view=modules&amp;layout=modal&amp;tmpl=component&amp;editor='
. $name . '&amp;' . JSession::getFormToken() . '=1';

return $button;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_MODULE_BUTTON_MODULE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";

return $button;
}
}
}
25 changes: 16 additions & 9 deletions plugins/editors-xtd/pagebreak/pagebreak.php
Expand Up @@ -33,16 +33,23 @@ class PlgButtonPagebreak extends JPlugin
*/
public function onDisplay($name)
{
$link = 'index.php?option=com_content&amp;view=article&amp;layout=pagebreak&amp;tmpl=component&amp;e_name=' . $name;
$user = JFactory::getUser();

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
$button->name = 'copy';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";
if ($user->authorise('core.create', 'com_content')
|| $user->authorise('core.edit', 'com_content')
|| $user->authorise('core.edit.own', 'com_content'))
{
$link = 'index.php?option=com_content&amp;view=article&amp;layout=pagebreak&amp;tmpl=component&amp;e_name=' . $name;

return $button;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
$button->name = 'copy';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";

return $button;
}
}
}

0 comments on commit 8acabc8

Please sign in to comment.