Button.php
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* @package Better Preview
* @version 6.1.0
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2018 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Plugin\System\BetterPreview\Component\Content\Article;
defined('_JEXEC') or die;
use RegularLabs\Plugin\System\BetterPreview\Component\Button as Main_Button;
use RegularLabs\Plugin\System\BetterPreview\Component\Menu;
class Button extends Main_Button
{
public function getExtraJavaScript($text)
{
return '
text = text.split(\'<hr id="system-readmore">\');
introtext = text[0];
fulltext = text[1] == undefined ? "" : text[1];
text = (introtext + " " + fulltext).trim();
cat = document.getElementById("jform_catid");
category_title = cat == undefined ? "" : cat.options[cat.selectedIndex].text.replace(/^(\s*-\s+)*/, "").trim();
overrides = {
text: text,
introtext: introtext,
fulltext: fulltext,
category_title: category_title,
};
';
}
public function getURL($name)
{
if ( ! $item = Helper::getArticle())
{
return false;
}
Menu::setItemId($item);
return $item->url;
}
}