Complete refactoring of serendipity_event_typesetbuttons
- Add new syntax for s9y 2.0 - Add button classes - Add unit tests
This commit is contained in:
parent
d53c388ddd
commit
51710d37e9
36
serendipity_event_typesetbuttons/buttons/AccentButton.php
Normal file
36
serendipity_event_typesetbuttons/buttons/AccentButton.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class AccentButton
|
||||
*/
|
||||
class AccentButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insaccent');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_ACCENT_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#x0301\\;','')");
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('́');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
36
serendipity_event_typesetbuttons/buttons/AmpButton.php
Normal file
36
serendipity_event_typesetbuttons/buttons/AmpButton.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class AmpButton
|
||||
*/
|
||||
class AmpButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insamp');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_AMP_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#38\\;','')");
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('&');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
73
serendipity_event_typesetbuttons/buttons/AposButton.php
Normal file
73
serendipity_event_typesetbuttons/buttons/AposButton.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class AposButton
|
||||
*/
|
||||
class AposButton extends Button
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useRealApos = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insapos');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_APOS_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUseRealApos()
|
||||
{
|
||||
return $this->useRealApos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $useRealApos
|
||||
*/
|
||||
public function setUseRealApos($useRealApos)
|
||||
{
|
||||
$this->useRealApos = $useRealApos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseRealApos() === false) {
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea(
|
||||
) . "'],'’','')"
|
||||
);
|
||||
} else {
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea(
|
||||
) . "'],'’','')"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#39\\;','')"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag(''');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
40
serendipity_event_typesetbuttons/buttons/BulletButton.php
Normal file
40
serendipity_event_typesetbuttons/buttons/BulletButton.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class BulletButton
|
||||
*/
|
||||
class BulletButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insbull');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_BULLET_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&bull\\;','')");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#8226\\;','')");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('•');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
265
serendipity_event_typesetbuttons/buttons/Button.php
Normal file
265
serendipity_event_typesetbuttons/buttons/Button.php
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?php
|
||||
require_once 'ButtonInterface.php';
|
||||
|
||||
/**
|
||||
* Class button
|
||||
*/
|
||||
abstract class Button implements ButtonInterface
|
||||
{
|
||||
/**
|
||||
* Textarea the button gets attached to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $textarea;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $onClickEvent;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $classes = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isXhtml11 = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useNamedEnts = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isLegacyMode = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $openTag;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $closeTag;
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
$this->setTextarea($textarea);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTextarea()
|
||||
{
|
||||
return $this->textarea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function setTextarea($textarea)
|
||||
{
|
||||
$this->textarea = $textarea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getClasses()
|
||||
{
|
||||
return $this->classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classes
|
||||
*/
|
||||
public function setClasses($classes)
|
||||
{
|
||||
$this->classes = $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*/
|
||||
public function addClass($class)
|
||||
{
|
||||
if (!in_array($class, $this->getClasses())) {
|
||||
$this->classes[] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnClickEvent()
|
||||
{
|
||||
return $this->onClickEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $onClickEvent
|
||||
*/
|
||||
public function setOnClickEvent($onClickEvent)
|
||||
{
|
||||
$this->onClickEvent = $onClickEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isXhtml11()
|
||||
{
|
||||
return $this->isXhtml11;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $isXhtml11
|
||||
*/
|
||||
public function setIsXhtml11($isXhtml11)
|
||||
{
|
||||
$this->isXhtml11 = $isXhtml11;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUseNamedEnts()
|
||||
{
|
||||
return $this->useNamedEnts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $useNamedEnts
|
||||
*/
|
||||
public function setUseNamedEnts($useNamedEnts)
|
||||
{
|
||||
$this->useNamedEnts = $useNamedEnts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLegacyMode()
|
||||
{
|
||||
return $this->isLegacyMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $isLegayMode
|
||||
*/
|
||||
public function setIsLegacyMode($isLegayMode)
|
||||
{
|
||||
$this->isLegacyMode = $isLegayMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCloseTag()
|
||||
{
|
||||
return $this->closeTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $closeTag
|
||||
*/
|
||||
public function setCloseTag($closeTag)
|
||||
{
|
||||
$this->closeTag = $closeTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOpenTag()
|
||||
{
|
||||
return $this->openTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $openTag
|
||||
*/
|
||||
public function setOpenTag($openTag)
|
||||
{
|
||||
$this->openTag = $openTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$html = sprintf(
|
||||
'<input type="button" class="%s" name="%s" value="%s" onclick="%s" />',
|
||||
implode(' ', $this->getClasses()),
|
||||
$this->getName(),
|
||||
$this->getValue(),
|
||||
$this->getOnClickEvent()
|
||||
);
|
||||
} else {
|
||||
$html = sprintf(
|
||||
'<button class="%s" type="button" name="%s" data-tag-open="%s" data-tag-close="%s" data-tarea="%s">%s</button>',
|
||||
implode(' ', $this->getClasses()),
|
||||
$this->getName(),
|
||||
$this->getOpenTag(),
|
||||
$this->getCloseTag(),
|
||||
$this->getTextarea(),
|
||||
$this->getValue()
|
||||
);
|
||||
}
|
||||
return ' ' . $html . PHP_EOL;
|
||||
}
|
||||
}
|
41
serendipity_event_typesetbuttons/buttons/ButtonInterface.php
Normal file
41
serendipity_event_typesetbuttons/buttons/ButtonInterface.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Interface ButtonInterface
|
||||
*/
|
||||
interface ButtonInterface
|
||||
{
|
||||
/**
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea);
|
||||
|
||||
/**
|
||||
* @param boolean $isXhtml11
|
||||
*/
|
||||
public function setIsXhtml11($isXhtml11);
|
||||
|
||||
/**
|
||||
* @param boolean $useNamedEnts
|
||||
*/
|
||||
public function setUseNamedEnts($useNamedEnts);
|
||||
|
||||
/**
|
||||
* @param boolean $isLegacyMode
|
||||
*/
|
||||
public function setIsLegacyMode($isLegacyMode);
|
||||
|
||||
/**
|
||||
* @param string $openTag
|
||||
*/
|
||||
public function setOpenTag($openTag);
|
||||
|
||||
/**
|
||||
* @param string $closeTag
|
||||
*/
|
||||
public function setCloseTag($closeTag);
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render();
|
||||
}
|
42
serendipity_event_typesetbuttons/buttons/CenterButton.php
Normal file
42
serendipity_event_typesetbuttons/buttons/CenterButton.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class button
|
||||
*/
|
||||
class CenterButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('inscenter');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_CENTER_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isXhtml11()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'<div class=\\'s9y_typeset s9y_typeset_center\\' style=\\'text-align: center; margin: 0px auto 0px auto\\'>','</div>')");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'<center>','</center>')");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->addClass('lang-html');
|
||||
$this->setOpenTag('p style=\'text-align: center;\'');
|
||||
$this->setCloseTag('p');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
70
serendipity_event_typesetbuttons/buttons/CustomButton.php
Normal file
70
serendipity_event_typesetbuttons/buttons/CustomButton.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class CustomButton
|
||||
*/
|
||||
class CustomButton extends Button
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $open;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $close;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClose()
|
||||
{
|
||||
return $this->close;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $close
|
||||
*/
|
||||
public function setClose($close)
|
||||
{
|
||||
$this->close = $close;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOpen()
|
||||
{
|
||||
return $this->open;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $open
|
||||
*/
|
||||
public function setOpen($open)
|
||||
{
|
||||
$this->open = $open;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'], '" . $this->getOpen(
|
||||
) . "', '" . $this->getClose() . "')"
|
||||
);
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag($this->getOpen());
|
||||
$this->setCloseTag($this->getClose());
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
137
serendipity_event_typesetbuttons/buttons/DquotesButton.php
Normal file
137
serendipity_event_typesetbuttons/buttons/DquotesButton.php
Normal file
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class DquotesButton
|
||||
*/
|
||||
class DquotesButton extends Button
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insdquote');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->overwriteValue();
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "']," . $this->getSurroundingNamedEntitiesStringByType() . ")");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "']," . $this->getSurroundingStringByType() . ")");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$namedEntities = $this->getCleanSurroundingStringByType();
|
||||
$tags = explode(',', $namedEntities);
|
||||
$this->setOpenTag(trim($tags[0], '\''));
|
||||
$this->setCloseTag(trim($tags[1], '\''));
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the value property according to given type
|
||||
*/
|
||||
private function overwriteValue()
|
||||
{
|
||||
$typeNumber = (int) preg_replace('$type$', '', $this->getType());
|
||||
$constName = 'PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES' . $typeNumber . '_BUTTON';
|
||||
parent::setValue(constant($constName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getSurroundingStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'\\&\\#8220\\;','\\&\\#8221\\;'",
|
||||
'type2' => "'\\&\\#8222\\;','\\&\\#8220\\;'",
|
||||
'type3' => "'\\&\\#8222\\;','\\&\\#8221\\;'",
|
||||
'type4' => "'\\&\\#8221\\;','\\&\\#8221\\;'",
|
||||
'type5' => "'\\&\\#8220\\;','\\&\\#8222\\;'",
|
||||
'type6' => "'\\&\\#171\\;\\&\\#160\\;','\\&\\#160\\;\\&\\#187\\;'",
|
||||
'type7' => "'\\&\\#187\\;','\\&\\#171\\;'",
|
||||
'type8' => "'\\&\\#187\\;','\\&\\#187\\;'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getSurroundingNamedEntitiesStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'\\&ldquo\\;','\\&rdquo\\;'",
|
||||
'type2' => "'\\&bdquo\\;','\\&ldquo\\;'",
|
||||
'type3' => "'\\&bdquo\\;','\\&rdquo\\;'",
|
||||
'type4' => "'\\&rdquo\\;','\\&rdquo\\;'",
|
||||
'type5' => "'\\&ldquo\\;','\\&bdquo\\;'",
|
||||
'type6' => "'\\&\\#171\\;\\&\\#160\\;','\\&\\#160\\;\\&\\#187\\;'",
|
||||
'type7' => "'\\&\\#187\\;','\\&\\#171\\;'",
|
||||
'type8' => "'\\&\\#187\\;','\\&\\#187\\;'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getCleanSurroundingStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'“','”'",
|
||||
'type2' => "'„','“'",
|
||||
'type3' => "'„','”'",
|
||||
'type4' => "'”','”'",
|
||||
'type5' => "'“','„'",
|
||||
'type6' => "'« ',' »'",
|
||||
'type7' => "'»','«'",
|
||||
'type8' => "'»','»'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
}
|
40
serendipity_event_typesetbuttons/buttons/EmdashButton.php
Normal file
40
serendipity_event_typesetbuttons/buttons/EmdashButton.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class EmdashButton
|
||||
*/
|
||||
class EmdashButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insemd');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_EMDASH_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&mdash\\;','')");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#8212\\;','')");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('—');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
40
serendipity_event_typesetbuttons/buttons/EndashButton.php
Normal file
40
serendipity_event_typesetbuttons/buttons/EndashButton.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class EndashButton
|
||||
*/
|
||||
class EndashButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insend');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_ENDASH_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&ndash\\;','')");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#8211\\;','')");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('–');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
38
serendipity_event_typesetbuttons/buttons/GaccentButton.php
Normal file
38
serendipity_event_typesetbuttons/buttons/GaccentButton.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class GaccentButton
|
||||
*/
|
||||
class GaccentButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insgaccent');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_GACCENT_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#x0300\\;','')"
|
||||
);
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag('̀');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
38
serendipity_event_typesetbuttons/buttons/SpaceButton.php
Normal file
38
serendipity_event_typesetbuttons/buttons/SpaceButton.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class SpaceButton
|
||||
*/
|
||||
class SpaceButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insSpace');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'\\&\\#160\\;','')"
|
||||
);
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->setOpenTag(' ');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
137
serendipity_event_typesetbuttons/buttons/SquotesButton.php
Normal file
137
serendipity_event_typesetbuttons/buttons/SquotesButton.php
Normal file
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class SquotesButton
|
||||
*/
|
||||
class SquotesButton extends Button
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('inssquote');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->overwriteValue();
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isUseNamedEnts()) {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "']," . $this->getSurroundingNamedEntitiesStringByType() . ")");
|
||||
} else {
|
||||
$this->setOnClickEvent("wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "']," . $this->getSurroundingStringByType() . ")");
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$namedEntities = $this->getCleanSurroundingStringByType();
|
||||
$tags = explode(',', $namedEntities);
|
||||
$this->setOpenTag(trim($tags[0], '\''));
|
||||
$this->setCloseTag(trim($tags[1], '\''));
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the value property according to given type
|
||||
*/
|
||||
private function overwriteValue()
|
||||
{
|
||||
$typeNumber = (int) preg_replace('$type$', '', $this->getType());
|
||||
$constName = 'PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES' . $typeNumber . '_BUTTON';
|
||||
parent::setValue(constant($constName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getSurroundingStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'\\&\\#8216\\;','\\&\\#8217\\;'",
|
||||
'type2' => "'\\&\\#8218\\;','\\&\\#8216\\;'",
|
||||
'type3' => "'\\&\\#8218\\;','\\&\\#8217\\;'",
|
||||
'type4' => "'\\&\\#8217\\;','\\&\\#8217\\;'",
|
||||
'type5' => "'\\&\\#8216\\;','\\&\\#8218\\;'",
|
||||
'type6' => "'\\&\\#8249\\;','\\&\\#8250\\;'",
|
||||
'type7' => "'\\&\\#8250\\;','\\&\\#8249\\;'",
|
||||
'type8' => "'\\&\\#8250\\;','\\&\\#8250\\;'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getSurroundingNamedEntitiesStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'\\&lsquo\\;','\\&rsquo\\;'",
|
||||
'type2' => "'\\&sbquo\\;','\\&lsquo\\;'",
|
||||
'type3' => "'\\&sbquo\\;','\\&rsquo\\;'",
|
||||
'type4' => "'\\&rsquo\\;','\\&rsquo\\;'",
|
||||
'type5' => "'\\&lsquo\\;','\\&sbquo\\;'",
|
||||
'type6' => "'\\&lsaquo\\;','\\&rsaquo\\;'",
|
||||
'type7' => "'\\&rsaquo\\;','\\&lsaquo\\;'",
|
||||
'type8' => "'\\&rsaquo\\;','\\&rsaquo\\;'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getCleanSurroundingStringByType()
|
||||
{
|
||||
$surroundingStrings = array(
|
||||
'type1' => "'‘','’'",
|
||||
'type2' => "'‚','‘'",
|
||||
'type3' => "'‚','’'",
|
||||
'type4' => "'’','’'",
|
||||
'type5' => "'‘','‚'",
|
||||
'type6' => "'‹','›'",
|
||||
'type7' => "'›','‹'",
|
||||
'type8' => "'›','›'",
|
||||
);
|
||||
if (!array_key_exists($this->getType(), $surroundingStrings)) {
|
||||
return $surroundingStrings['type1'];
|
||||
}
|
||||
return $surroundingStrings[$this->getType()];
|
||||
}
|
||||
}
|
46
serendipity_event_typesetbuttons/buttons/StrikeButton.php
Normal file
46
serendipity_event_typesetbuttons/buttons/StrikeButton.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
require_once 'Button.php';
|
||||
|
||||
/**
|
||||
* Class button
|
||||
*/
|
||||
class StrikeButton extends Button
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $textarea
|
||||
*/
|
||||
public function __construct($textarea)
|
||||
{
|
||||
parent::__construct($textarea);
|
||||
$this->setName('insstrike');
|
||||
$this->setValue(PLUGIN_EVENT_TYPESETBUTTONS_STRIKE_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->isLegacyMode()) {
|
||||
$this->addClass('serendipityPrettyButton');
|
||||
$this->addClass('input_button');
|
||||
if ($this->isXhtml11()) {
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'<del>','</del>')"
|
||||
);
|
||||
} else {
|
||||
$this->setOnClickEvent(
|
||||
"wrapSelection(document.forms['serendipityEntry']['" . $this->getTextarea() . "'],'<s>','</s>')"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->addClass('wrap_selection');
|
||||
$this->addClass('lang-html');
|
||||
$this->setOpenTag('p style=\'text-decoration: line-through;\'');
|
||||
$this->setCloseTag('p');
|
||||
}
|
||||
return parent::render();
|
||||
}
|
||||
}
|
|
@ -1,37 +1,46 @@
|
|||
<?php
|
||||
|
||||
# serendipity_event_typesetbuttons.php,v 0.1 12/21/2004 18:08:24
|
||||
|
||||
if (IN_serendipity !== true) {
|
||||
die ("Don't hack!");
|
||||
}
|
||||
|
||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||
|
||||
// Probe for a language include with constants. Still include defines later on, if some constants were missing
|
||||
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
|
||||
if (file_exists($probelang)) {
|
||||
include $probelang;
|
||||
}
|
||||
|
||||
include dirname(__FILE__) . '/lang_en.inc.php';
|
||||
|
||||
/**
|
||||
* Class serendipity_event_typesetbuttons
|
||||
*/
|
||||
class serendipity_event_typesetbuttons extends serendipity_event
|
||||
{
|
||||
var $title = PLUGIN_EVENT_TYPESETBUTTONS_TITLE;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $title = PLUGIN_EVENT_TYPESETBUTTONS_TITLE;
|
||||
|
||||
function introspect(&$propbag)
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $txtarea;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $legacy = false;
|
||||
|
||||
/**
|
||||
* @param serendipity_property_bag $propbag
|
||||
* @return true|void
|
||||
*/
|
||||
public function introspect(&$propbag)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_TITLE);
|
||||
$propbag->add('description', PLUGIN_EVENT_TYPESETBUTTONS_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Matthew Groeninger, Malte Diers');
|
||||
$propbag->add('version', '0.11');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_TITLE);
|
||||
$propbag->add('description', PLUGIN_EVENT_TYPESETBUTTONS_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Matthew Groeninger, Malte Diers, Matthias Gutjahr');
|
||||
$propbag->add('version', '0.22');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '1.7',
|
||||
'smarty' => '2.6.7',
|
||||
'php' => '4.1.0'
|
||||
'php' => '5.3.3'
|
||||
));
|
||||
$propbag->add('configuration', array(
|
||||
'enable_center',
|
||||
|
@ -55,14 +64,19 @@ class serendipity_event_typesetbuttons extends serendipity_event
|
|||
'use_named_ents',
|
||||
'custom'
|
||||
));
|
||||
$propbag->add('event_hooks', array(
|
||||
$propbag->add('event_hooks', array(
|
||||
'backend_entry_toolbar_extended' => true,
|
||||
'backend_entry_toolbar_body' => true
|
||||
));
|
||||
$propbag->add('groups', array('BACKEND_EDITOR'));
|
||||
}
|
||||
|
||||
function introspect_config_item($name, &$propbag)
|
||||
/**
|
||||
* @param string $name
|
||||
* @param serendipity_property_bag $propbag
|
||||
* @return bool
|
||||
*/
|
||||
public function introspect_config_item($name, &$propbag)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'custom':
|
||||
|
@ -291,358 +305,167 @@ class serendipity_event_typesetbuttons extends serendipity_event
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
||||
/**
|
||||
* @param string $event
|
||||
* @param serendipity_property_bag $bag
|
||||
* @param array $eventData
|
||||
* @return bool|true
|
||||
*/
|
||||
public function event_hook($event, &$bag, &$eventData) {
|
||||
global $serendipity;
|
||||
|
||||
if (intval($serendipity['version'][0]) < 2) {
|
||||
$this->legacy = true;
|
||||
}
|
||||
$hooks = &$bag->get('event_hooks');
|
||||
$pluginConfigurationKeys = $bag->get('configuration');
|
||||
if (isset($hooks[$event])) {
|
||||
switch($event) {
|
||||
switch ($event) {
|
||||
case 'backend_entry_toolbar_extended':
|
||||
if (!$serendipity['wysiwyg']) {
|
||||
if (isset($eventData['backend_entry_toolbar_extended:textarea'])) {
|
||||
$txtarea = $eventData['backend_entry_toolbar_extended:textarea'];
|
||||
} else {
|
||||
$txtarea = "serendipity[extended]";
|
||||
}
|
||||
$this->generate_button($txtarea);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $this->processEvent('extended', $eventData, $pluginConfigurationKeys);
|
||||
break;
|
||||
|
||||
case 'backend_entry_toolbar_body':
|
||||
if (!$serendipity['wysiwyg']) {
|
||||
if (isset($eventData['backend_entry_toolbar_body:textarea'])) {
|
||||
$txtarea = $eventData['backend_entry_toolbar_body:textarea'];
|
||||
} else {
|
||||
$txtarea = "serendipity[body]";
|
||||
}
|
||||
$this->generate_button($txtarea);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $this->processEvent('body', $eventData, $pluginConfigurationKeys);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function generate_content(&$title) {
|
||||
/**
|
||||
* @param string $type
|
||||
* @param array $eventData
|
||||
* @param array $pluginConfigurationKeys
|
||||
* @return bool
|
||||
*/
|
||||
private function processEvent($type, $eventData, $pluginConfigurationKeys)
|
||||
{
|
||||
global $serendipity;
|
||||
if (!$serendipity['wysiwyg']) {
|
||||
if (isset($eventData['backend_entry_toolbar_' . $type . ':textarea'])) {
|
||||
$txtarea = $eventData['backend_entry_toolbar_' . $type . ':textarea'];
|
||||
} else {
|
||||
$txtarea = "serendipity[" . $type . "]";
|
||||
}
|
||||
$this->generate_button($txtarea, $pluginConfigurationKeys);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param string $title
|
||||
* @return null|void
|
||||
*/
|
||||
public function generate_content(&$title) {
|
||||
$title = PLUGIN_EVENT_TYPESETBUTTONS_TITLE;
|
||||
}
|
||||
|
||||
function generate_button($txtarea) {
|
||||
global $serendipity;
|
||||
if (!isset($txtarea)) {
|
||||
$txtarea = 'body';
|
||||
/**
|
||||
* @param string $txtarea
|
||||
* @param array $pluginConfigurationKeys
|
||||
*/
|
||||
private function generate_button($txtarea, array $pluginConfigurationKeys) {
|
||||
global $serendipity; // required for optional logging of exceptions
|
||||
if (!isset($txtarea)) {
|
||||
$txtarea = 'body';
|
||||
}
|
||||
$this->txtarea = $txtarea;
|
||||
foreach ($pluginConfigurationKeys as $configKey) {
|
||||
$keyParts = explode('_', $configKey);
|
||||
if ($keyParts[0] !== 'enable' || $this->get_config($configKey) !== 'yes') {
|
||||
continue;
|
||||
}
|
||||
if ($this->get_config('enable_center') == 'yes') {
|
||||
if ($this->get_config('use_xhtml11','yes') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inscenter" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_CENTER_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'<div class=\'s9y_typeset s9y_typeset_center\' style=\'text-align: center; margin: 0px auto 0px auto\'>','</div>')" />
|
||||
<?php
|
||||
try {
|
||||
if ($keyParts[1] === 'dquotes') {
|
||||
echo $html = $this->getButton($keyParts[1], $this->get_config('type_dquotes', 'type1'));
|
||||
} elseif ($keyParts[1] === 'squotes') {
|
||||
echo $html = $this->getButton($keyParts[1], $this->get_config('type_squotes', 'type1'));
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inscenter" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_CENTER_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'<center>','</center>')" />
|
||||
<?php
|
||||
echo $html = $this->getButton($keyParts[1]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Uncomment the next three lines for debugging:
|
||||
// $fp = fopen($serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/' . get_class($this) . '.log', 'a');
|
||||
// fwrite($fp, $e->getMessage() . PHP_EOL);
|
||||
// fclose($fp);
|
||||
continue;
|
||||
}
|
||||
if ($this->get_config('enable_strike') == 'yes') {
|
||||
if ($this->get_config('use_xhtml11','yes') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insstrike" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_STRIKE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'<del>','</del>')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insstrike" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_STRIKE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'<s>','</s>')" />
|
||||
<?php
|
||||
}
|
||||
$custom = $this->get_config('custom');
|
||||
$custom = trim($custom);
|
||||
if (!empty($custom)) {
|
||||
echo '<br />';
|
||||
$parts = explode('|', $custom);
|
||||
foreach ($parts as $part) {
|
||||
$part = trim($part);
|
||||
if (empty($part)) {
|
||||
continue;
|
||||
}
|
||||
echo $this->getCustomButton($txtarea, $part);
|
||||
}
|
||||
if ($this->get_config('enable_space') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insSpace" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#160\;','')" />
|
||||
<?php
|
||||
}
|
||||
if ($this->get_config('enable_amp') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insamp" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_AMP_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#38\;','')" />
|
||||
<?php
|
||||
}
|
||||
if ($this->get_config('enable_emdash') == 'yes') {
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insemd" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_EMDASH_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&mdash\;','')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insemd" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_EMDASH_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8212\;','')" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ($this->get_config('enable_endash') == 'yes') {
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insend" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_ENDASH_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&ndash\;','')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insend" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_ENDASH_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8211\;','')" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ($this->get_config('enable_bullet') == 'yes') {
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insbull" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_BULLET_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&bull\;','')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insbull" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_BULLET_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8226\;','')" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ($this->get_config('enable_dquotes') == 'yes') {
|
||||
switch($this->get_config('type_dquotes','type1')) {
|
||||
case'type1':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES1_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&ldquo\;','\&rdquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES1_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8220\;','\&\#8221\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type2':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES2_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&bdquo\;','\&ldquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES2_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8222\;','\&\#8220\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type3':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES3_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&bdquo\;','\&rdquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES3_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8222\;','\&\#8221\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type4':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES4_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&rdquo\;','\&rdquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES4_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8221\;','\&\#8221\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type5':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES5_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&ldquo\;','\&bdquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES5_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8220\;','\&\#8222\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type6':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES6_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#171\;\&\#160\;','\&\#160\;\&\#187\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES6_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#171\;\&\#160\;','\&\#160\;\&\#187\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type7':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES7_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#187\;','\&\#171\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES7_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#187\;','\&\#171\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type8':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES8_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#187\;','\&\#187\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES8_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#187\;','\&\#187\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|null $type
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
private function getButton($name, $type = null)
|
||||
{
|
||||
$name = ucfirst($name);
|
||||
$class = $name . 'Button';
|
||||
$classFile = 'buttons/' . $name . 'Button.php';
|
||||
if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . $classFile)) {
|
||||
throw new Exception($classFile . ' not found.');
|
||||
}
|
||||
require_once $classFile;
|
||||
/** @var ButtonInterface $button */
|
||||
$button = new $class($this->txtarea);
|
||||
$button->setIsLegacyMode($this->legacy);
|
||||
if ($this->get_config('use_xhtml11') !== 'yes') {
|
||||
$button->setIsXhtml11(false);
|
||||
}
|
||||
if ($this->get_config('use_named_ents') !== 'yes') {
|
||||
$button->setUseNamedEnts(false);
|
||||
}
|
||||
if ($type !== null && method_exists($button, 'setType')) {
|
||||
$button->setType($type);
|
||||
}
|
||||
if (method_exists($button, 'setUseRealApos')) {
|
||||
if ($this->get_config('real_apos', 'yes') === 'no') {
|
||||
$button->setUseRealApos(false);
|
||||
} else {
|
||||
$button->setUseRealApos(true);
|
||||
}
|
||||
if ($this->get_config('enable_squotes') == 'yes') {
|
||||
switch($this->get_config('type_squotes','type1')) {
|
||||
case'type1':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES1_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&lsquo\;','\&rsquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES1_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8216\;','\&\#8217\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type2':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES2_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&sbquo\;','\&lsquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES2_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8218\;','\&\#8216\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type3':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES3_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&sbquo\;','\&rsquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES3_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8218\;','\&\#8217\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type4':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES4_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&rsquo\;','\&rsquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES4_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8217\;','\&\#8217\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type5':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES5_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&lsquo\;','\&sbquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES5_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8216\;','\&\#8218\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type6':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES6_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&lsaquo\;','\&rsaquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES6_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8249\;','\&\#8250\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type7':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES7_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&rsaquo\;','\&lsaquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES7_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8250\;','\&\#8249\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case'type8':
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES8_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&rsaquo\;','\&rsaquo\;')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES8_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8250\;','\&\#8250\;')" />
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $button->render();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($this->get_config('enable_apos') == 'yes') {
|
||||
if ($this->get_config('real_apos','yes') == 'no') {
|
||||
if ($this->get_config('use_named_ents') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insapos" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_APOS_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&rsquo\;','')" />
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insapos" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_APOS_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#8217\;','')" />
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insapos" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_APOS_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#39\;','')" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ($this->get_config('enable_accent') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insaccent" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_ACCENT_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#x0301\;','')" />
|
||||
<?php
|
||||
}
|
||||
if ($this->get_config('enable_gaccent') == 'yes') {
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="insgaccent" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_GACCENT_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'],'\&\#x0300\;','')" />
|
||||
<?php
|
||||
}
|
||||
|
||||
$custom = $this->get_config('custom');
|
||||
$custom = trim($custom);
|
||||
if (!empty($custom)) {
|
||||
echo '<br />';
|
||||
$parts = explode('|', $custom);
|
||||
foreach($parts AS $idx => $part) {
|
||||
$part = trim($part);
|
||||
if (empty($part)) continue;
|
||||
|
||||
$buttons = explode('@', $part);
|
||||
$b_name = htmlspecialchars($buttons[0]);
|
||||
$b_title = preg_replace('@[^a-z0-9]@i', '_', $buttons[0]);
|
||||
$b_open = str_replace(array('"', "'"), array('"', "\\'"), $buttons[1]);
|
||||
$b_close = str_replace(array('"', "'"), array('"', "\\'"), $buttons[2]);
|
||||
?>
|
||||
<input type="button" class="serendipityPrettyButton input_button" name="ins_custom_<?php echo $b_title; ?>" value="<?php echo $b_name; ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'], '<?php echo $b_open; ?>', '<?php echo $b_close; ?>')" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $txtarea
|
||||
* @param string $part
|
||||
* @return string
|
||||
*/
|
||||
private function getCustomButton($txtarea, $part)
|
||||
{
|
||||
$buttons = explode('@', $part);
|
||||
$b_name = htmlspecialchars($buttons[0]);
|
||||
$b_title = preg_replace('@[^a-z0-9]@i', '_', $buttons[0]);
|
||||
$b_open = str_replace(array('"', "'"), array('"', "\\'"), $buttons[1]);
|
||||
$b_close = str_replace(array('"', "'"), array('"', "\\'"), $buttons[2]);
|
||||
require_once 'buttons/CustomButton.php';
|
||||
$button = new CustomButton($txtarea);
|
||||
$button->setIsLegacyMode($this->legacy);
|
||||
$button->setName('ins_custom_' . $b_name);
|
||||
$button->setValue($b_title);
|
||||
$button->setOpen($b_open);
|
||||
$button->setClose($b_close);
|
||||
return $button->render();
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/AccentButton.php';
|
||||
|
||||
/**
|
||||
* Class AccentButtonTest
|
||||
*/
|
||||
class AccentButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var AccentButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new AccentButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insaccent" data-tag-open="́" data-tag-close="" data-tarea="serendipity[body]"> ́</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insaccent" value=" ́" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#x0301\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/AmpButton.php';
|
||||
|
||||
/**
|
||||
* Class AmpButtonTest
|
||||
*/
|
||||
class AmpButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var AccentButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new AmpButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insamp" data-tag-open="&" data-tag-close="" data-tarea="serendipity[body]">&</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insamp" value="&" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#38\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/AposButton.php';
|
||||
|
||||
/**
|
||||
* Class AposButtonTest
|
||||
*/
|
||||
class AposButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var AposButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new AposButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insapos" data-tag-open="'" data-tag-close="" data-tarea="serendipity[body]">'</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insapos" value="'" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#39\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoRealApos()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseRealApos(false);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insapos" value="'" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'’\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoRealAposAndNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseRealApos(false);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insapos" value="'" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'’\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/BulletButton.php';
|
||||
|
||||
/**
|
||||
* Class BulletButtonTest
|
||||
*/
|
||||
class BulletButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var BulletButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new BulletButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insbull" data-tag-open="•" data-tag-close="" data-tarea="serendipity[body]">•</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insbull" value="•" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&bull\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insbull" value="•" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8226\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/CenterButton.php';
|
||||
|
||||
/**
|
||||
* Class CenterButtonTest
|
||||
*/
|
||||
class CenterButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var CenterButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new CenterButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection lang-html" type="button" name="inscenter" data-tag-open="p style=\'text-align: center;\'" data-tag-close="p" data-tarea="serendipity[body]">Center</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setIsXhtml11(false);
|
||||
$expected = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inscenter\" value=\"Center\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[body]'],'<center>','</center>')\" />" . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeAndXhtml11()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inscenter\" value=\"Center\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[body]'],'<div class=\\'s9y_typeset s9y_typeset_center\\' style=\\'text-align: center; margin: 0px auto 0px auto\\'>','</div>')\" />" . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/CustomButton.php';
|
||||
|
||||
/**
|
||||
* Class CustomButtonTest
|
||||
*/
|
||||
class CustomButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var CustomButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new CustomButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider getCustomData
|
||||
*/
|
||||
public function render($name, $openTag, $closeTag)
|
||||
{
|
||||
$this->button->setName('ins_custom_' . $name);
|
||||
$this->button->setValue($name);
|
||||
$this->button->setOpen($openTag);
|
||||
$this->button->setClose($closeTag);
|
||||
$expected = ' <button class="wrap_selection" type="button" name="ins_custom_' . $name . '" data-tag-open="' . $openTag . '" data-tag-close="' . $closeTag . '" data-tarea="serendipity[body]">' . $name . '</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider getCustomData
|
||||
*/
|
||||
public function renderInLegacyMode($name, $openTag, $closeTag)
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setName('ins_custom_' . $name);
|
||||
$this->button->setValue($name);
|
||||
$this->button->setOpen($openTag);
|
||||
$this->button->setClose($closeTag);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="ins_custom_' . $name . '" value="' . $name . '" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'' . $openTag . '\', \'' . $closeTag . '\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for custom buttons
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomData()
|
||||
{
|
||||
return array(
|
||||
array('code', '<code>', '</code>'),
|
||||
array('pre', '<pre>', '</pre>'),
|
||||
array('bash', '[geshi lang=bash]', '[/geshi]'),
|
||||
array('perl', '[geshi lang=perl]', '[/geshi]'),
|
||||
array('sql', '[geshi lang=sql]', '[/geshi]'),
|
||||
array('li', '<li>', '</li>'),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/DquotesButton.php';
|
||||
|
||||
/**
|
||||
* Class DquotesButtonTest
|
||||
*/
|
||||
class DquotesButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var DquotesButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new DquotesButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider getNamedEntities
|
||||
*/
|
||||
public function render($type, $openTag, $closeTag, $namedEntity)
|
||||
{
|
||||
$this->button->setType($type);
|
||||
$html = sprintf(
|
||||
'<button class="wrap_selection" type="button" name="insdquote" data-tag-open="%s" data-tag-close="%s" data-tarea="serendipity[body]">%s</button>',
|
||||
$openTag,
|
||||
$closeTag,
|
||||
$namedEntity
|
||||
);
|
||||
$expected = ' ' . $html . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for named entities
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNamedEntities()
|
||||
{
|
||||
return array(
|
||||
array('type1', '“', '”', '“ ”'),
|
||||
array('type2', '„', '“', '„ “'),
|
||||
array('type3', '„', '”', '„ ”'),
|
||||
array('type4', '”', '”', '” ”'),
|
||||
array('type5', '“', '„', '“ „'),
|
||||
array('type6', '« ', ' »', '« »'),
|
||||
array('type7', '»', '«', '» «'),
|
||||
array('type8', '»', '»', '» »'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setType('type1');
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="“ ”" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&ldquo\\;\',\'\\&rdquo\\;\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$this->button->setType('type1');
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insdquote" value="“ ”" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8220\\;\',\'\\&\\#8221\\;\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/EmdashButton.php';
|
||||
|
||||
/**
|
||||
* Class EmdashButtonTest
|
||||
*/
|
||||
class EmdashButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var EmdashButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new EmdashButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$html = sprintf(
|
||||
'<button class="wrap_selection" type="button" name="insemd" data-tag-open="%s" data-tag-close="%s" data-tarea="serendipity[body]">%s</button>',
|
||||
'—',
|
||||
'',
|
||||
'—'
|
||||
);
|
||||
$expected = ' ' . $html . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insemd" value="—" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&mdash\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insemd" value="—" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8212\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/EndashButton.php';
|
||||
|
||||
/**
|
||||
* Class EndashButtonTest
|
||||
*/
|
||||
class EndashButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var EndashButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new EndashButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$html = sprintf(
|
||||
'<button class="wrap_selection" type="button" name="insend" data-tag-open="%s" data-tag-close="%s" data-tarea="serendipity[body]">%s</button>',
|
||||
'–',
|
||||
'',
|
||||
'–'
|
||||
);
|
||||
$expected = ' ' . $html . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insend" value="–" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&ndash\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insend" value="–" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8211\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/GaccentButton.php';
|
||||
|
||||
/**
|
||||
* Class GaccentButtonTest
|
||||
*/
|
||||
class GaccentButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var GaccentButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new GaccentButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insgaccent" data-tag-open="̀" data-tag-close="" data-tarea="serendipity[body]"> ̀</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insgaccent" value=" ̀" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#x0300\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/SpaceButton.php';
|
||||
|
||||
/**
|
||||
* Class SpaceButtonTest
|
||||
*/
|
||||
class SpaceButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var SpaceButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new SpaceButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection" type="button" name="insSpace" data-tag-open=" " data-tag-close="" data-tarea="serendipity[body]">Space</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="insSpace" value="Space" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#160\\;\',\'\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/SquotesButton.php';
|
||||
|
||||
/**
|
||||
* Class SquotesButtonTest
|
||||
*/
|
||||
class SquotesButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var SquotesButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new SquotesButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider getNamedEntities
|
||||
*/
|
||||
public function render($type, $openTag, $closeTag, $namedEntity)
|
||||
{
|
||||
$this->button->setType($type);
|
||||
$html = sprintf(
|
||||
'<button class="wrap_selection" type="button" name="inssquote" data-tag-open="%s" data-tag-close="%s" data-tarea="serendipity[body]">%s</button>',
|
||||
$openTag,
|
||||
$closeTag,
|
||||
$namedEntity
|
||||
);
|
||||
$expected = ' ' . $html . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for named entities
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNamedEntities()
|
||||
{
|
||||
return array(
|
||||
array('type1', '‘', '’', '‘ ’'),
|
||||
array('type2', '‚', '‘', '‚ ‘'),
|
||||
array('type3', '‚', '’', '‚ ’'),
|
||||
array('type4', '’', '’', '’ ’'),
|
||||
array('type5', '‘', '‚', '‘ ‚'),
|
||||
array('type6', '‹', '›', '‹ ›'),
|
||||
array('type7', '›', '‹', '› ‹'),
|
||||
array('type8', '›', '›', '› ›'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setType('type1');
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="‘ ’" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&lsquo\\;\',\'\\&rsquo\\;\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeNoNamedEnts()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setUseNamedEnts(false);
|
||||
$this->button->setType('type1');
|
||||
$expected = ' <input type="button" class="serendipityPrettyButton input_button" name="inssquote" value="‘ ’" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'\\&\\#8216\\;\',\'\\&\\#8217\\;\')" />' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../../buttons/StrikeButton.php';
|
||||
|
||||
/**
|
||||
* Class StrikeButtonTest
|
||||
*/
|
||||
class StrikeButtonTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var StrikeButton
|
||||
*/
|
||||
protected $button;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->button = new StrikeButton('serendipity[body]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$expected = ' <button class="wrap_selection lang-html" type="button" name="insstrike" data-tag-open="p style=\'text-decoration: line-through;\'" data-tag-close="p" data-tarea="serendipity[body]">Strike</button>' . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyMode()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$this->button->setIsXhtml11(false);
|
||||
$expected = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insstrike\" value=\"Strike\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[body]'],'<s>','</s>')\" />" . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderInLegacyModeAndXhtml11()
|
||||
{
|
||||
$this->button->setIsLegacyMode(true);
|
||||
$expected = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insstrike\" value=\"Strike\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[body]'],'<del>','</del>')\" />" . PHP_EOL;
|
||||
$this->assertEquals($expected, $this->button->render());
|
||||
}
|
||||
}
|
349
serendipity_event_typesetbuttons/tests/typesetbuttonsTest.php
Normal file
349
serendipity_event_typesetbuttons/tests/typesetbuttonsTest.php
Normal file
|
@ -0,0 +1,349 @@
|
|||
<?php
|
||||
|
||||
require_once S9Y_INCLUDE_PATH . 'tests/plugins/PluginTest.php';
|
||||
require_once S9Y_INCLUDE_PATH . 'plugins/additional_plugins/serendipity_event_typesetbuttons/serendipity_event_typesetbuttons.php';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class serendipity_event_typesetbuttonsTest extends PluginTest
|
||||
{
|
||||
/**
|
||||
* @var serendipity_event_typesetbuttons
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* @var serendipity_property_bag
|
||||
*/
|
||||
protected $propBag;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $eventData;
|
||||
|
||||
/**
|
||||
* Set up
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->object = new serendipity_event_typesetbuttons('test');
|
||||
$this->propBag = new serendipity_property_bag();
|
||||
$this->getEventData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method
|
||||
*/
|
||||
protected function getEventData()
|
||||
{
|
||||
$this->eventData = array(
|
||||
'id' => 1,
|
||||
'body' => 'Normal body.',
|
||||
'extended' => 'Extended body.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Example 1
|
||||
* @test
|
||||
*/
|
||||
public function introspect()
|
||||
{
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->assertEquals('Typeset/Extended Buttons for non-WYSIWYG editors', $this->propBag->get('name'));
|
||||
$this->assertFalse($this->propBag->get('stackable'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function generateContent()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$title = 'foobar'; // we need to pass this by reference
|
||||
$this->object->generate_content($title);
|
||||
$this->assertEquals('Typeset/Extended Buttons for non-WYSIWYG editors', $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function wrongEventShouldReturnFalse()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->assertFalse($this->object->event_hook('frontend_comment', $this->propBag, $this->eventData));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarShouldNotBeAffectedIfWysiwygIsActive()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = true; // WYSIWYG editor is active
|
||||
$this->object->introspect($this->propBag);
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithExtendedTextareaShouldOutputButtons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11Output('serendipity[extended]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithExtendedTextareaShouldOutputCustomButtons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$customButtons = <<<EOT
|
||||
code@<code>@</code>|
|
||||
pre@<pre>@</pre>|
|
||||
bash@[geshi lang=bash]@[/geshi]|
|
||||
perl@[geshi lang=perl]@[/geshi]|
|
||||
sql@[geshi lang=sql]@[/geshi]|
|
||||
li@<li>@</li>
|
||||
EOT;
|
||||
$this->object->set_config('custom', $customButtons);
|
||||
$this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11OutputWithCustomButtons('serendipity[extended]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithExtendedTextareaShouldOutputXhtml11Buttons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->object->set_config('use_xhtml11', 'no');
|
||||
$this->eventData['backend_entry_toolbar_extended:textarea'] = 'serendipity[extended]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getXhtml11Output('serendipity[extended]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithCustomTextareaShouldOutputButtons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->eventData['backend_entry_toolbar_extended:textarea'] = 'foobar';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_extended', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11Output('foobar'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithBodyTextareaShouldOutputButtons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11Output('serendipity[body]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function disabledButtonsShouldNotBeDisplayed()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '2.0.0';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->object->set_config('enable_center', 'no');
|
||||
$this->object->set_config('enable_strike', 'no');
|
||||
$this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11OutputWithoutDisabledButtons('serendipity[body]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function disabledButtonsShouldNotBeDisplayedInLegacyMode()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->object->set_config('enable_center', 'no');
|
||||
$this->object->set_config('enable_strike', 'no');
|
||||
$this->eventData['backend_entry_toolbar_body:textarea'] = 'serendipity[body]';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11OutputWithoutDisabledButtonsInLegacyMode('serendipity[body]'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function extendedToolbarWithCustomBodyTextareaShouldOutputButtons()
|
||||
{
|
||||
global $serendipity;
|
||||
$serendipity['version'] = '1.7.8';
|
||||
$serendipity['wysiwyg'] = false; // WYSIWYG editor is inactive
|
||||
$this->object->introspect($this->propBag);
|
||||
$this->eventData['backend_entry_toolbar_body:textarea'] = 'foobar';
|
||||
$result = $this->object->event_hook('backend_entry_toolbar_body', $this->propBag, $this->eventData);
|
||||
$this->expectOutputString($this->getNotXhtml11Output('foobar'));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
* @return string
|
||||
*/
|
||||
private function getXhtml11Output($textarea = "serendipity[extended]")
|
||||
{
|
||||
$output = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inscenter\" value=\"Center\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<center>','</center>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insstrike\" value=\"Strike\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<s>','</s>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insSpace\" value=\"Space\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#160\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insamp\" value=\"&\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#38\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insemd\" value=\"—\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&mdash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insend\" value=\"–\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ndash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insbull\" value=\"•\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&bull\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insdquote\" value=\"“ ”\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ldquo\\;','\\&rdquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inssquote\" value=\"‘ ’\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&lsquo\\;','\\&rsquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insapos\" value=\"'\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#39\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insaccent\" value=\" ́\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0301\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insgaccent\" value=\" ̀\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0300\\;','')\" />
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
* @return string
|
||||
*/
|
||||
private function getNotXhtml11Output($textarea = "serendipity[extended]")
|
||||
{
|
||||
$output = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inscenter\" value=\"Center\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<div class=\\'s9y_typeset s9y_typeset_center\\' style=\\'text-align: center; margin: 0px auto 0px auto\\'>','</div>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insstrike\" value=\"Strike\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<del>','</del>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insSpace\" value=\"Space\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#160\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insamp\" value=\"&\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#38\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insemd\" value=\"—\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&mdash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insend\" value=\"–\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ndash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insbull\" value=\"•\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&bull\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insdquote\" value=\"“ ”\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ldquo\\;','\\&rdquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inssquote\" value=\"‘ ’\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&lsquo\\;','\\&rsquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insapos\" value=\"'\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#39\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insaccent\" value=\" ́\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0301\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insgaccent\" value=\" ̀\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0300\\;','')\" />
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
* @return string
|
||||
*/
|
||||
private function getNotXhtml11OutputWithoutDisabledButtons($textarea = "serendipity[extended]")
|
||||
{
|
||||
$output = " <button class=\"wrap_selection\" type=\"button\" name=\"insSpace\" data-tag-open=\" \" data-tag-close=\"\" data-tarea=\"serendipity[body]\">Space</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insamp\" data-tag-open=\"&\" data-tag-close=\"\" data-tarea=\"serendipity[body]\">&</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insemd\" data-tag-open=\"—\" data-tag-close=\"\" data-tarea=\"serendipity[body]\">—</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insend\" data-tag-open=\"–\" data-tag-close=\"\" data-tarea=\"serendipity[body]\">–</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insbull\" data-tag-open=\"•\" data-tag-close=\"\" data-tarea=\"serendipity[body]\">•</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insdquote\" data-tag-open=\"“\" data-tag-close=\"”\" data-tarea=\"serendipity[body]\">“ ”</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"inssquote\" data-tag-open=\"‘\" data-tag-close=\"’\" data-tarea=\"serendipity[body]\">‘ ’</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insapos\" data-tag-open=\"'\" data-tag-close=\"\" data-tarea=\"serendipity[body]\">'</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insaccent\" data-tag-open=\"́\" data-tag-close=\"\" data-tarea=\"serendipity[body]\"> ́</button>
|
||||
<button class=\"wrap_selection\" type=\"button\" name=\"insgaccent\" data-tag-open=\"̀\" data-tag-close=\"\" data-tarea=\"serendipity[body]\"> ̀</button>
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
* @return string
|
||||
*/
|
||||
private function getNotXhtml11OutputWithoutDisabledButtonsInLegacyMode($textarea = "serendipity[extended]")
|
||||
{
|
||||
$output = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insSpace\" value=\"Space\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#160\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insamp\" value=\"&\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#38\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insemd\" value=\"—\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&mdash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insend\" value=\"–\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ndash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insbull\" value=\"•\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&bull\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insdquote\" value=\"“ ”\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ldquo\\;','\\&rdquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inssquote\" value=\"‘ ’\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&lsquo\\;','\\&rsquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insapos\" value=\"'\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#39\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insaccent\" value=\" ́\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0301\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insgaccent\" value=\" ̀\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0300\\;','')\" />
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $textarea
|
||||
* @return string
|
||||
*/
|
||||
private function getNotXhtml11OutputWithCustomButtons($textarea = "serendipity[extended]")
|
||||
{
|
||||
$output = " <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inscenter\" value=\"Center\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<div class=\\'s9y_typeset s9y_typeset_center\\' style=\\'text-align: center; margin: 0px auto 0px auto\\'>','</div>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insstrike\" value=\"Strike\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'<del>','</del>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insSpace\" value=\"Space\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#160\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insamp\" value=\"&\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#38\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insemd\" value=\"—\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&mdash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insend\" value=\"–\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ndash\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insbull\" value=\"•\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&bull\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insdquote\" value=\"“ ”\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&ldquo\\;','\\&rdquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"inssquote\" value=\"‘ ’\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&lsquo\\;','\\&rsquo\\;')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insapos\" value=\"'\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#39\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insaccent\" value=\" ́\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0301\\;','')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"insgaccent\" value=\" ̀\" onclick=\"wrapSelection(document.forms['serendipityEntry']['" . $textarea . "'],'\\&\\#x0300\\;','')\" />
|
||||
<br /> <input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_code\" value=\"code\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '<code>', '</code>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_pre\" value=\"pre\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '<pre>', '</pre>')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_bash\" value=\"bash\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '[geshi lang=bash]', '[/geshi]')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_perl\" value=\"perl\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '[geshi lang=perl]', '[/geshi]')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_sql\" value=\"sql\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '[geshi lang=sql]', '[/geshi]')\" />
|
||||
<input type=\"button\" class=\"serendipityPrettyButton input_button\" name=\"ins_custom_li\" value=\"li\" onclick=\"wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'], '<li>', '</li>')\" />
|
||||
";
|
||||
return $output;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue