Skip to content

Commit

Permalink
2.0 compat fix for the buttons
Browse files Browse the repository at this point in the history
Reuses the serendipity_editor.js.tpl without breaking bc, and adds the wysiwyg-emit-call, therefore reusing the method used in the core entry editor
  • Loading branch information
onli committed Mar 31, 2014
1 parent 14fae00 commit 258bb83
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
2 changes: 2 additions & 0 deletions serendipity_event_staticpage/ChangeLog
@@ -1,3 +1,5 @@
4.06 Serendipity 2.0 compatibility fix for the editorbuttons (wysiwyg and default)

4.05 Bump version to propagate changed plugin_staticpage_related_category.tpl

4.04 Bump version to propagate new .htaccess
Expand Down
55 changes: 28 additions & 27 deletions serendipity_event_staticpage/serendipity_event_staticpage.php
Expand Up @@ -92,7 +92,7 @@ function introspect(&$propbag)
$propbag->add('page_configuration', $this->config);
$propbag->add('type_configuration', $this->config_types);
$propbag->add('author', 'Marco Rinck, Garvin Hicking, David Rolston, Falk Doering, Stephan Manske, Pascal Uhlmann, Ian, Don Chambers');
$propbag->add('version', '4.05');
$propbag->add('version', '4.06');
$propbag->add('requirements', array(
'serendipity' => '1.3',
'smarty' => '2.6.7',
Expand Down Expand Up @@ -2310,43 +2310,41 @@ function inspectConfig($is_smarty, $what, $elcount, $config_item, $config_value,
&nbsp;<span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span></td>
<td align="right">
<?php
/* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */
}

if (!$serendipity['wysiwyg'] && preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {
if (!$serendipity['wysiwyg']) {
?> <nobr><span id="tools_<?php echo $config_item ?>" style="display: none">
<?php if( $serendipity['nl2br']['iso2br'] ) { ?>
<input type="button" class="serendipityPrettyButton input_button" name="insX" value="NoBR" accesskey="x" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<nl>','</nl>')" />
<?php } ?>
<input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<em>','</em>')" />
<input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<strong>','</strong>')" />
<input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<u>','</u>')" />
<input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<blockquote>','</blockquote>')" />
<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])" />
<input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?>" style="" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo urlencode('serendipity[plugin]['.$config_item.']'); ?>', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" />
<input type="button" class="serendipityPrettyButton input_button" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])" />
</span></nobr>
<?php
/* Do the "old" non-WYSIWYG editor */
} else {
?> <nobr><span id="tools_<?php echo $config_item ?>" style="display: none">
<?php if( $serendipity['nl2br']['iso2br'] ) { ?>
<input type="button" class="serendipityPrettyButton input_button" value=" NoBR " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'], 'x')" />
<?php } ?>
<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'], 'b')">
<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'], 'u')">
<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'], 'i')">
<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])">
<input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?>" onclick="window.open('serendipity_admin_image_selector.php?serendipity[filename_only]=<?php echo $config_item ?>', 'ImageSel', 'width=800,height=600,toolbar=no');">
<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])">
<input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insI" value="I" accesskey="i" data-tarea="nuggets<?php echo $elcount; ?>" data-tag="em" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<em>','</em>')" />
<input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insB" value="B" accesskey="b" data-tarea="nuggets<?php echo $elcount; ?>" data-tag="strong" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<strong>','</strong>')" />
<input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insU" value="U" accesskey="u" data-tarea="nuggets<?php echo $elcount; ?>" data-tag="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<u>','</u>')" />
<input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" data-tarea="nuggets<?php echo $elcount; ?>" data-tag="blockquote" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'],'<blockquote>','</blockquote>')" />
<input type="button" class="serendipityPrettyButton input_button wrap_insimg" name="insJ" value="img" accesskey="j" data-tarea="nuggets<?php echo $elcount; ?>" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])" />
<?php
if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) {
?>
<button class="wrap_insmedia" type="button" name="insImage" data-tarea="nuggets<?php echo $elcount; ?>"><?php echo MEDIA; ?></button>
<?php
} else {
?>
<input type="button" class="serendipityPrettyButton input_button wrap_insmedia" name="insImage" value="<?php echo MEDIA; ?>" style="" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo urlencode('serendipity[plugin]['.$config_item.']'); ?>', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" />
<?php
}
?>
<input type="button" class="serendipityPrettyButton input_button wrap_insurl" name="insU" value="URL" accesskey="l" data-tarea="nuggets<?php echo $elcount; ?>" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item ?>]'])" />
</span></nobr>
<?php } ?>
<script type="text/javascript" language="JavaScript">
var tb_<?php echo $config_item ?> = document.getElementById('tools_<?php echo $config_item ?>');
tb_<?php echo $config_item ?>.style.display = '';

</script>
<?php

<?php
if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) {
?><script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js') ?>"></script><?php
}
// add extra data in the entry's array so that emoticonchooser plugin
// behaves well with wysiwyg editors, then clean up ;-) (same apply below)
$entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount;
Expand All @@ -2362,7 +2360,10 @@ function inspectConfig($is_smarty, $what, $elcount, $config_item, $config_value,
<td>
<?php
}

if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) {
serendipity_emit_htmlarea_code("nuggets{$elcount}","");
?><script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js') ?>"></script><?php
}
$entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount;
$entry['backend_entry_toolbar_body:textarea'] = 'serendipity[plugin][' . $config_item . ']';
serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry);
Expand Down

0 comments on commit 258bb83

Please sign in to comment.