CoreFiles by mySites.guru
readmore.php73 lines, 1,775 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
58cfffe30fa6afab02581ba91094c9c9
sha1
701cf4c23e67ffb30a644243bb6f7bea2396146e
sha256
ac9af9e799c2158ac2170d9a23fcde660f7e2aff40fa083833ac2c8c4b61a943
<?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\Event\Event;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\CMSPlugin;

/**
 * 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;
	}
}

No other release has this exact content. See every version of this file.