CoreFiles by mySites.guru
readmore.php73 lines, 1,775 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
d67d673d8cf8ae1c1d93ce64af05866d
sha1
db6dd429605bf876d2a0530285dc7a8ce9cf87c6
sha256
990f653e8227d0ed5e520db188265d001ad2df0b0279fc82decbb54bc7bd5c03
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Editors-xtd.readmore
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\Event;

/**
 * Editor Readmore button
 *
 * @since  1.5
 */
class PlgButtonReadmore extends CMSPlugin
{
	/**
	 * Load the language file on instantiation.
	 *
	 * @var    boolean
	 * @since  3.1
	 */
	protected $autoloadLanguage = true;

	/**
	 * Readmore button
	 *
	 * @param   string  $name  The name of the button to add
	 *
	 * @return  CMSObject  $button  A two element array of (imageName, textToInsert)
	 *
	 * @since   1.5
	 */
	public function onDisplay($name)
	{
		// Button is not active in specific content components
		$event = new Event(
			'getContent',
			['name' => $name]
		);

		$getContentResult = $this->getDispatcher()->dispatch('getContent', $event);
		$getContent = $getContentResult['result'][0];
		HTMLHelper::_('script', 'com_content/admin-article-readmore.min.js', array('version' => 'auto', 'relative' => true));

		// Pass some data to javascript
		Factory::getDocument()->addScriptOptions(
			'xtd-readmore',
			array(
				'editor' => $getContent,
				'exists' => Text::_('PLG_READMORE_ALREADY_EXISTS', true),
			)
		);

		$button = new CMSObject;
		$button->modal   = false;
		$button->onclick = 'insertReadmore(\'' . $name . '\');return false;';
		$button->text    = Text::_('PLG_READMORE_BUTTON_READMORE');
		$button->name    = 'arrow-down';
		$button->link    = '#';

		return $button;
	}
}

The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.