Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

[imp] Move editor-readmore overridable code to layout. Fixes #44. Fixes #10 #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions layouts/plugins/editors-xtd/readmore/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

extract($displayData);

/**
* Layout variables
* ---------------------
* $getContent : (string) The content being passed to the plugin
* $present : (string) Alert message
*/

$script = "
function insertReadmore(editor)
{
var content = $getContent
if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i))
{
alert('$present');
return false;
} else {
jInsertEditorText('<hr id=\"system-readmore\" />', editor);
}
}
";

JFactory::getDocument()->addScriptDeclaration($script);
23 changes: 6 additions & 17 deletions plugins/editors-xtd/readmore/readmore.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,16 @@ class PlgButtonReadmore extends JPlugin
*/
public function onDisplay($name)
{
$doc = JFactory::getDocument();

// Button is not active in specific content components

$getContent = $this->_subject->getContent($name);
$present = JText::_('PLG_READMORE_ALREADY_EXISTS', true);
$js = "
function insertReadmore(editor)
{
var content = $getContent
if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i))
{
alert('$present');
return false;
} else {
jInsertEditorText('<hr id=\"system-readmore\" />', editor);
}
}
";

$doc->addScriptDeclaration($js);
$this->getRenderer('default')->render(
array(
'getContent' => $getContent,
'present' => $present
)
);

$button = new JObject;
$button->modal = false;
Expand Down