CoreFiles by mySites.guru
readmore.php74 lines, 1,906 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
8936ebd7f02dacdb422a43e8468d582f
sha1
c514903f4b038d1a73adebd6e11e403abdabcf30
sha256
318c7e50c0f03b622dc1e506cdbe6aa025c96377abb5c8ba9c3b1002acd6efe9
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Editors-xtd.readmore
 *
 * @copyright   Copyright (C) 2005 - 2019 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->iconSVG = '<svg viewBox="0 0 32 32" width="24" height="24"><path d="M32 12l-6-6-10 10-10-10-6 6 16 16z"></path></svg>';
		$button->link    = '#';

		return $button;
	}
}

The same content is in 5 releases, Joomla 4.0.0-alpha8 to 4.0.0-alpha12. See them all, or every version of this file.