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.10');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('configuration', array(
'enable_center',
'enable_strike',
'enable_space',
'enable_amp',
'enable_emdash',
'enable_endash',
'enable_bullet',
'enable_dquotes',
'type_dquote_info',
'type_dquotes',
'enable_squotes',
'type_squote_info',
'type_squotes',
'enable_apos',
'real_apos',
'enable_accent',
'enable_gaccent',
'use_xhtml11',
'use_named_ents',
'custom'
));
$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)
{
switch ($name) {
case 'custom':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_CUSTOM);
$propbag->add('description', PLUGIN_EVENT_TYPESETBUTTONS_CUSTOM_DESC);
$propbag->add('default', '');
break;
case 'use_xhtml11':
$propbag->add('type', 'radio');
$propbag->add('name', INSTALL_XHTML11);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'use_named_ents':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_USED_NAMED_ENTS);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_strike':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_STRIKE_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_center':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_CENTER_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_space':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_SPACE_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_amp':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_AMP_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_emdash':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_EMDASH_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_endash':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_ENDASH_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_bullet':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_BULLET_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_dquotes':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_DQUOTES_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'type_dquotes':
if ($this->get_config('enable_dquotes') == 'yes') {
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_TYPE_DQUOTES_BUTTON);
$propbag->add('radio',
array( 'value' => array('type1','type2','type3','type4','type5','type6','type7','type8'),
'desc' => array(PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES1,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES2,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES3,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES4,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES5,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES6,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES7,PLUGIN_EVENT_TYPESETBUTTONS_DBQUOTES8)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'type1');
}
break;
case 'type_dquote_info':
if ($this->get_config('enable_dquotes') == 'yes') {
$propbag->add('type', 'content');
$propbag->add('default', PLUGIN_EVENT_TYPESETBUTTONS_TYPE_DQUOTES_NOTE);
}
break;
case 'enable_squotes':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_SQUOTES_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'type_squotes':
if ($this->get_config('enable_squotes') == 'yes') {
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_TYPE_SQUOTES_BUTTON);
$propbag->add('radio',
array( 'value' => array('type1','type2','type3','type4','type5','type6','type7','type8'),
'desc' => array(PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES1,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES2,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES3,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES4,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES5,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES6,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES7,PLUGIN_EVENT_TYPESETBUTTONS_SQUOTES8)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'type1');
}
break;
case 'type_squote_info':
if ($this->get_config('enable_squotes') == 'yes') {
$propbag->add('type', 'content');
$propbag->add('default', PLUGIN_EVENT_TYPESETBUTTONS_TYPE_SQUOTES_NOTE);
}
break;
case 'enable_apos':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_APOS_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'real_apos':
if ($this->get_config('enable_apos') == 'yes') {
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_REAL_APOS);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
}
break;
case 'enable_accent':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_ACCENT_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
case 'enable_gaccent':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_TYPESETBUTTONS_ENABLE_GACCENT_BUTTON);
$propbag->add('radio',
array( 'value' => array('yes','no'),
'desc' => array(YES,NO)
));
$propbag->add('radio_per_row', '2');
$propbag->add('default', 'yes');
break;
default:
return false;
}
return true;
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$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;
}
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;
}
break;
default:
return false;
break;
}
} else {
return false;
}
}
function generate_content(&$title) {
$title = PLUGIN_EVENT_TYPESETBUTTONS_TITLE;
}
function generate_button($txtarea) {
global $serendipity;
if (!isset($txtarea)) {
$txtarea = 'body';
}
if ($this->get_config('enable_center') == 'yes') {
if ($this->get_config('use_xhtml11','yes') == 'yes') {
?>
get_config('enable_strike') == 'yes') {
if ($this->get_config('use_xhtml11','yes') == 'yes') {
?>
get_config('enable_space') == 'yes') {
?>
get_config('enable_amp') == 'yes') {
?>
get_config('enable_emdash') == 'yes') {
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('enable_endash') == 'yes') {
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('enable_bullet') == 'yes') {
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('enable_dquotes') == 'yes') {
switch($this->get_config('type_dquotes','type1')) {
case'type1':
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('enable_squotes') == 'yes') {
switch($this->get_config('type_squotes','type1')) {
case'type1':
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('use_named_ents') == 'yes') {
?>
get_config('enable_apos') == 'yes') {
if ($this->get_config('real_apos','yes') == 'no') {
if ($this->get_config('use_named_ents') == 'yes') {
?>
get_config('enable_accent') == 'yes') {
?>
get_config('enable_gaccent') == 'yes') {
?>
get_config('custom');
$custom = trim($custom);
if (!empty($custom)) {
echo '
';
$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]);
?>