update includeentry plugin

This commit is contained in:
Ian 2015-06-01 13:24:48 +02:00
parent c7db2ca834
commit 8cebd6ddf4
7 changed files with 372 additions and 136 deletions

View file

@ -1,3 +1,12 @@
2.15
- prepare for Serendipity 2.0 and check for (window.Spawnnuggets)
- fix 'show_multi' option non-template file fatal error
- db table set to use UTF8 on install
- extend required version
2.14.1
- use serendipity_specialchars
2.14
- fixed $serendipity['author'] to be $serendipity['serendipityUser'];

View file

@ -1,4 +1,4 @@
<?php
@define('PLUGIN_EVENT_INCLUDEENTRY_NAME', 'Textformatierung: Eintragsdaten einfügen');
@define('PLUGIN_EVENT_INCLUDEENTRY_DESC', 'Ermöglicht das Hinzufügen von HTML-ähnlichen Tags um Teile von anderen Einträgen einzubinden. Benutzen Sie folgende Formatierung: [s9y-include-entry:XXX:YYY]. Ersetzen Sie XXX mit der Ziel-ID des Eintrags und YYY mit dem Zielfeldnamen der Datenbank (z.B. "body", "extended", "title" usw.).');
@define('PLUGIN_EVENT_INCLUDEENTRY_NAME', 'Textformatierung: Eintragsdaten einfügen');
@define('PLUGIN_EVENT_INCLUDEENTRY_DESC', 'Ermöglicht das Hinzufügen von HTML-ähnlichen Tags um Teile von anderen Einträgen einzubinden. Benutzen Sie folgende Formatierung: [s9y-include-entry:XXX:YYY]. Ersetzen Sie XXX mit der Ziel-ID des Eintrags und YYY mit dem Zielfeldnamen der Datenbank (z.B. "body", "extended", "title" usw.).');

View file

@ -1,5 +1,6 @@
<br /><hr />
<table border="0" cellspacing="0" cellpadding="3" width="100%">
<div class="clearfix">
<?php
$elcount = 0;
$htmlnugget = array();
@ -36,40 +37,27 @@
switch ($cbag->get('type')) {
case 'seperator':
?>
<tr>
<td colspan="2"><hr noshade="noshade" size="1" /></td>
</tr>
<hr>
<?php
break;
case 'select':
$select = $cbag->get('select_values');
?>
<tr>
<td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?></strong>
<?php
if ($cdesc != '') {
?>
<br><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
<?php } ?>
</td>
<td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250">
<div>
<select class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]">
<div class="clearfix form_select<?php if ($cdesc != '') { ?> has_info<?php } ?>">
<label for="serendipity_<?php echo $config_item; ?>"><?php echo $cname; ?><?php if ($cdesc != '') { ?> <button class="toggle_info button_link" type="button" data-href="#<?php echo $config_item; ?>_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> <?php echo MORE; ?></span></button><?php } ?></label>
<?php if ($cdesc != '') { ?><span id="<?php echo $config_item; ?>_info" class="field_info additional_info"><?php echo $cdesc; ?></span><?php } ?>
<select id="serendipity_<?php echo $config_item; ?>" class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]{($is_multi_select) ? '[]' : ''}" {($is_multi_select) ? 'multiple' : ''} {($is_multi_select && ($select_size > 0)) ? "size='{$select_size}'" : ''}>
<?php
foreach($select AS $select_value => $select_desc) {
$id = (function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET));
?>
<option value="<?php echo $select_value; ?>" <?php echo ($select_value == $hvalue ? 'selected="selected"' : ''); ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?>" />
<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?>
</option>
<option value="<?php echo $select_value; ?>" <?php echo ($select_value == $hvalue ? 'selected="selected"' : ''); ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?>"><?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?></option>
<?php
}
?>
</select>
</div>
</td>
</tr>
</select>
</div>
<?php
break;
@ -97,17 +85,10 @@
}
}
?>
<tr>
<td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?></strong>
<?php
if ($cdesc != '') {
?>
<br /><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
<?php
}
?>
</td>
<td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250">
<fieldset<?php if ($cdesc != '') { ?> class="has_info"<?php } ?>>
<span class="wrap_legend"><legend><?php echo $cname; ?><?php if ($cdesc != '') { ?> <button class="toggle_info button_link" type="button" data-href="#<?php echo $config_item; ?>_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> <?php echo MORE; ?></span></button><?php } ?></legend></span>
<?php if ($cdesc != '') { ?><span id="<?php echo $config_item; ?>_info" class="field_info additional_info"><?php echo $cdesc; ?></span><?php } ?>
<div class="clearfix grouped">
<?php
$counter = 0;
foreach($radio['value'] AS $radio_index => $radio_value) {
@ -125,75 +106,71 @@
if ($counter == 1) {
?>
<div>
<div class="form_radio">
<?php
}
?>
<input class="direction_<?php echo $lang_direction; ?> input_radio" type="radio" id="serendipity_plugin_<?php echo $id; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $radio_value; ?>" <?php echo $checked ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?>" />
<label for="serendipity_plugin_<?php echo $id; ?>"><?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?></label>
<input id="serendipity_plugin_<?php echo $id; ?>" class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" type="radio" value="<?php echo $radio_value; ?>" <?php echo $checked ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?>">
<label for="serendipity_plugin_<?php echo $id; ?>"><?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?></label>
<?php
if ($counter == $per_row) {
$counter = 0;
?>
</div>
</div>
<?php
}
}
?>
</td>
</tr>
</div>
</fieldset>
<?php
break;
case 'string':
?>
<tr>
<td style="border-bottom: 1px solid #000000">
<strong><?php echo $cname; ?></strong>
<br><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
</td>
<td style="border-bottom: 1px solid #000000" width="250">
<div>
<input class="direction_<?php echo $lang_direction; ?> input_textbox" type="text" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $hvalue; ?>" size="30" />
</div>
</td>
</tr>
<div class="clearfix configuration_group">
<div class="clearfix form_field<?php if ($cdesc != '') { ?> has_info<?php } ?>">
<label for="serendipity_<?php echo $config_item; ?>"><?php echo $cname; if ($cdesc != '') { ?> <button class="toggle_info button_link" type="button" data-href="#<?php echo $config_item; ?>_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> <?php echo MORE; ?></span></button><?php } ?></label>
<?php if ($cdesc != '') { ?><span id="<?php echo $config_item; ?>_info" class="field_info additional_info"><?php echo $cdesc; ?></span><?php } ?>
<input id="serendipity_<?php echo $config_item; ?>" class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" type="text" value="<?php echo $hvalue; ?>">
</div>
</div>
<?php
break;
case 'html':
case 'text':
?>
<tr>
<td colspan="2"><strong><?php echo $cname; ?></strong>
&nbsp;<span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
</td>
</tr>
<tr>
<td colspan="2">
<div>
<textarea class="direction_<?php echo $lang_direction; ?>" style="width: 100%" id="nuggets<?php echo $elcount; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
</div>
</td>
</tr>
<div class="clearfix form_area<?php if ($cdesc != '') { ?> has_info<?php } ?>">
<label for="nuggets<?php echo $elcount; ?>"><?php echo $cname; if ($cdesc != '' && !$backend_wysiwyg) { ?> <button class="toggle_info button_link" type="button" data-href="#nuggets<?php echo $elcount; ?>_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> <?php echo MORE; ?></span></button><?php } ?></label>
<?php if ($cdesc != '') { ?><span id="nuggets<?php echo $elcount; ?>_info" class="field_info additional_info"><?php echo $cdesc; ?></span><?php } ?>
<textarea id="nuggets<?php echo $elcount; ?>" class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="{$text_rows}"><?php echo $hvalue; ?></textarea>
</div>
<?php
if ($cbag->get('type') == 'html') {
$htmlnugget[] = $elcount;
if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) {
serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount);
} else {
serendipity_emit_htmlarea_code('nuggets', 'nuggets', true);
}
// SpawnMulti false per default (see multi nugget textareas, eg contactform) - where do we use jsname furthermore - or is that deprecated?
serendipity_emit_htmlarea_code("nuggets{$elcount}","nuggets{$elcount}");
}
break;
case 'content':
?><tr><td colspan="2"><?php echo $cbag->get('default'); ?></td></tr><?php
?>
<div class="clearfix">
<?php echo $cbag->get('default'); ?>
</div>
<?php
break;
case 'hidden':
?><tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?> input_textbox" type="hidden" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $cbag->get('value'); ?>" /></td></tr><?php
?>
<div class="clearfix">
<input name="serendipity[plugin][<?php echo $config_item; ?>]" type="hidden" value="<?php echo $cbag->get('value'); ?>">
</div>
<?php
break;
}
}
@ -206,12 +183,8 @@
?>
<script type="text/javascript">
function Spawnnugget() {
<?php foreach($htmlnugget AS $htmlnuggetid) {
if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) { ?>
Spawnnuggets<?php echo $htmlnuggetid; ?>();
<?php } else { ?>
Spawnnuggets('<?php echo $htmlnuggetid; ?>');
<?php } ?>
<?php foreach($htmlnugget AS $htmlnuggetid) { ?>
if (window.Spawnnuggets) Spawnnuggets('<?php echo $htmlnuggetid; ?>');
<?php } ?>
}
</script>
@ -219,8 +192,9 @@
}
}
?>
</table>
<br />
<div style="padding-left: 20px">
<input type="submit" name="serendipity[SAVECONF]" value="<?php echo SAVE; ?>" class="serendipityPrettyButton input_button" />
<div class="clearfix edit_actions">
<input class="input_button state_submit" type="submit" value="<?php echo SAVE; ?>" name="serendipity[SAVECONF]">
</div>
</div>

View file

@ -1,4 +1,4 @@
<?php
@define('PLUGIN_EVENT_INCLUDEENTRY_NAME', 'Textformatierung: Eintragsdaten einfügen');
@define('PLUGIN_EVENT_INCLUDEENTRY_DESC', 'Ermöglicht das Hinzufügen von HTML-ähnlichen Tags um Teile von anderen Einträgen einzubinden. Benutzen Sie folgende Formatierung: [s9y-include-entry:XXX:YYY]. Ersetzen Sie XXX mit der Ziel-ID des Eintrags und YYY mit dem Zielfeldnamen der Datenbank (z.B. "body", "extended", "title" usw.).');
@define('PLUGIN_EVENT_INCLUDEENTRY_NAME', 'Textformatierung: Eintragsdaten einfügen');
@define('PLUGIN_EVENT_INCLUDEENTRY_DESC', 'Ermöglicht das Hinzufügen von HTML-ähnlichen Tags um Teile von anderen Einträgen einzubinden. Benutzen Sie folgende Formatierung: [s9y-include-entry:XXX:YYY]. Ersetzen Sie XXX mit der Ziel-ID des Eintrags und YYY mit dem Zielfeldnamen der Datenbank (z.B. "body", "extended", "title" usw.).');

View file

@ -0,0 +1,226 @@
<br /><hr />
<table border="0" cellspacing="0" cellpadding="3" width="100%">
<?php
$elcount = 0;
$htmlnugget = array();
foreach ($this->config as $config_item) {
$elcount++;
$config_value = $this->staticpage[$config_item];
$cbag = new serendipity_property_bag;
$this->introspect_item($config_item, $cbag);
$cname = (function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('name')) : htmlspecialchars($cbag->get('name'), ENT_COMPAT, LANG_CHARSET));
$cdesc = (function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('description')) : htmlspecialchars($cbag->get('description'), ENT_COMPAT, LANG_CHARSET));
$value = $this->get_static($config_item, 'unset');
$lang_direction = (function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('lang_direction')) : htmlspecialchars($cbag->get('lang_direction'), ENT_COMPAT, LANG_CHARSET));
$only_type = $cbag->get('only_type');
if (!empty($only_type) && $type != $only_type) {
$elcount--;
continue;
}
if (empty($lang_direction)) {
$lang_direction = LANG_DIRECTION;
}
/* Apparently no value was set for this config item */
if ($value === 'unset') {
/* Try and the default value for the config item */
$value = $cbag->get('default');
}
$hvalue = (!isset($_POST["serendipity"]["staticSubmit"]) && isset($_POST['serendipity']['plugin'][$config_item]) ? (function_exists('serendipity_specialchars') ? serendipity_specialchars($_POST['serendipity']['plugin'][$config_item]) : htmlspecialchars($_POST['serendipity']['plugin'][$config_item], ENT_COMPAT, LANG_CHARSET)) : (function_exists('serendipity_specialchars') ? serendipity_specialchars($value) : htmlspecialchars($value, ENT_COMPAT, LANG_CHARSET)));
$radio = array();
$select = array();
$per_row = null;
switch ($cbag->get('type')) {
case 'seperator':
?>
<tr>
<td colspan="2"><hr noshade="noshade" size="1" /></td>
</tr>
<?php
break;
case 'select':
$select = $cbag->get('select_values');
?>
<tr>
<td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?></strong>
<?php
if ($cdesc != '') {
?>
<br><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
<?php } ?>
</td>
<td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250">
<div>
<select class="direction_<?php echo $lang_direction; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]">
<?php
foreach($select AS $select_value => $select_desc) {
$id = (function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET));
?>
<option value="<?php echo $select_value; ?>" <?php echo ($select_value == $hvalue ? 'selected="selected"' : ''); ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?>" />
<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)); ?>
</option>
<?php
}
?>
</select>
</div>
</td>
</tr>
<?php
break;
case 'tristate':
$per_row = 3;
$radio['value'][] = 'default';
$radio['desc'][] = USE_DEFAULT;
case 'boolean':
$radio['value'][] = 'true';
$radio['desc'][] = YES;
$radio['value'][] = 'false';
$radio['desc'][] = NO;
case 'radio':
if (!count($radio) > 0) {
$radio = $cbag->get('radio');
}
if (empty($per_row)) {
$per_row = $cbag->get('radio_per_row');
if (empty($per_row)) {
$per_row = 2;
}
}
?>
<tr>
<td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?></strong>
<?php
if ($cdesc != '') {
?>
<br /><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
<?php
}
?>
</td>
<td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250">
<?php
$counter = 0;
foreach($radio['value'] AS $radio_index => $radio_value) {
$id = (function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $radio_value) : htmlspecialchars($config_item . $radio_value, ENT_COMPAT, LANG_CHARSET));
$counter++;
$checked = "";
if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) {
$checked = " checked";
} elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue ==='0' || $hvalue === 'false')) {
$checked = " checked";
} elseif ($radio_value == $hvalue) {
$checked = " checked";
}
if ($counter == 1) {
?>
<div>
<?php
}
?>
<input class="direction_<?php echo $lang_direction; ?> input_radio" type="radio" id="serendipity_plugin_<?php echo $id; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $radio_value; ?>" <?php echo $checked ?> title="<?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?>" />
<label for="serendipity_plugin_<?php echo $id; ?>"><?php echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET)); ?></label>
<?php
if ($counter == $per_row) {
$counter = 0;
?>
</div>
<?php
}
}
?>
</td>
</tr>
<?php
break;
case 'string':
?>
<tr>
<td style="border-bottom: 1px solid #000000">
<strong><?php echo $cname; ?></strong>
<br><span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
</td>
<td style="border-bottom: 1px solid #000000" width="250">
<div>
<input class="direction_<?php echo $lang_direction; ?> input_textbox" type="text" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $hvalue; ?>" size="30" />
</div>
</td>
</tr>
<?php
break;
case 'html':
case 'text':
?>
<tr>
<td colspan="2"><strong><?php echo $cname; ?></strong>
&nbsp;<span style="color: #5E7A94; font-size: 8pt;">&nbsp;<?php echo $cdesc; ?></span>
</td>
</tr>
<tr>
<td colspan="2">
<div>
<textarea class="direction_<?php echo $lang_direction; ?>" style="width: 100%" id="nuggets<?php echo $elcount; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
</div>
</td>
</tr>
<?php
if ($cbag->get('type') == 'html') {
$htmlnugget[] = $elcount;
if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) {
serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount);
} else {
serendipity_emit_htmlarea_code('nuggets', 'nuggets', true);
}
}
break;
case 'content':
?><tr><td colspan="2"><?php echo $cbag->get('default'); ?></td></tr><?php
break;
case 'hidden':
?><tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?> input_textbox" type="hidden" name="serendipity[plugin][<?php echo $config_item; ?>]" value="<?php echo $cbag->get('value'); ?>" /></td></tr><?php
break;
}
}
if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) {
$ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false);
serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev);
if ($ev['skip_nuggets'] === false) {
?>
<script type="text/javascript">
function Spawnnugget() {
<?php foreach($htmlnugget AS $htmlnuggetid) {
if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) { ?>
Spawnnuggets<?php echo $htmlnuggetid; ?>();
<?php } else { ?>
Spawnnuggets('<?php echo $htmlnuggetid; ?>');
<?php } ?>
<?php } ?>
}
</script>
<?php
}
}
?>
</table>
<br />
<div style="padding-left: 20px">
<input type="submit" name="serendipity[SAVECONF]" value="<?php echo SAVE; ?>" class="serendipityPrettyButton input_button" />
</div>

View file

@ -1,7 +1,7 @@
<h3 class="serendipity_date">{$staticblock.timestamp|@formatTime:DATE_FORMAT_ENTRY}</h3>
<h4 class="serendipity_title">{$staticblock.title}</h4>
<div class="serendipity_entry">
<div class="serendipity_entry_body">{$staticblock.body}</div>
<div class="serendipity_entry_extended">{$staticblock.extended}</div>

View file

@ -38,10 +38,10 @@ class serendipity_event_includeentry extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_INCLUDEENTRY_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '2.14.1');
$propbag->add('version', '2.15');
$propbag->add('scrambles_true_content', true);
$propbag->add('requirements', array(
'serendipity' => '0.8',
'serendipity' => '1.7',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
@ -237,7 +237,7 @@ class serendipity_event_includeentry extends serendipity_event
function &getCategories() {
global $serendipity;
$html = '<strong>' . CATEGORIES . '</strong><br />';
$html = (($serendipity['version'][0] < 2) ? '<strong>' . CATEGORIES . '</strong><br />' : '<span class="wrap_legend"><legend>' . CATEGORIES . '</legend></span>') ."\n";
$all_valid = false;
if (is_array($serendipity['POST']['plugin']['enabled_categories'])) {
@ -253,16 +253,16 @@ class serendipity_event_includeentry extends serendipity_event
}
}
$html .= '<select name="serendipity[plugin][enabled_categories][]" multiple="true" size="5">';
$html .= '<option value="-front-" ' . ($all_valid || isset($valid['-front-']) ? "selected='selected'" : '') . '>[' . NO_CATEGORY . ']</option>';
$html .= '<select id="staticblock_enabled_categories" name="serendipity[plugin][enabled_categories][]" multiple="true" size="5">'."\n";
$html .= ' <option value="-front-" ' . ($all_valid || isset($valid['-front-']) ? "selected='selected'" : '') . '>[' . NO_CATEGORY . ']</option>'."\n";
if (is_array($cats = serendipity_fetchCategories())) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ( $cats as $cat ) {
$html .= '<option value="'. $cat['categoryid'] .'"'. ($all_valid || isset($valid[$cat['categoryid']]) ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
$html .= ' <option value="'. $cat['categoryid'] .'"'. ($all_valid || isset($valid[$cat['categoryid']]) ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
}
}
$html .= '</select>';
$html .= '</select>'."\n";
return $html;
}
@ -312,7 +312,7 @@ class serendipity_event_includeentry extends serendipity_event
$built = $this->get_config('db_built', null);
if (empty($built)) {
serendipity_db_schema_import("CREATE TABLE {$serendipity['dbPrefix']}staticblocks (
$q = "CREATE TABLE IF NOT EXISTS {$serendipity['dbPrefix']}staticblocks (
id {AUTOINCREMENT} {PRIMARY},
title varchar(255) not null default '',
type varchar(255) not null default '',
@ -320,11 +320,12 @@ class serendipity_event_includeentry extends serendipity_event
extended text,
template varchar(255) not null default '',
apply_markup int(1) default '0',
author varchar(20) default null,
authorid int(11) default null,
last_modified int(10) {UNSIGNED} default null,
timestamp int(10) {UNSIGNED} default null);");
timestamp int(10) {UNSIGNED} default null) {UTF_8}";
serendipity_db_schema_import($q);
$this->set_config('db_built', '1');
}
@ -332,12 +333,15 @@ class serendipity_event_includeentry extends serendipity_event
function showForm($type = 'template') {
global $serendipity;
// Code copied from include/admin/plugins.inc.php. Sue me. ;-)
if (file_exists(S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php')) {
if (!function_exists('serendipity_emit_htmlarea_code')) {
include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
}
include 'form.inc.php';
if ($serendipity['version'][0] < 2) {
include 'oldform.inc.php';
} else {
include 'form.inc.php';
}
}
// This function checks the values of a staticblock entry, and maybe adjusts the right values to use.
@ -392,13 +396,21 @@ class serendipity_event_includeentry extends serendipity_event
if (!isset($this->staticblock['id'])) {
$result = serendipity_db_insert('staticblocks', $this->staticblock);
if (is_string($result)) {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>';
if ($serendipity['version'][0] < 2) {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>'."\n";
} else {
echo '<div class="msg_error"><span class="icon-attention-circled"></span> ERROR: ' . $result . '</div>'."\n";
}
}
$serendipity["POST"]["staticblock"] = serendipity_db_insert_id("staticblocks", 'id');
} else {
$result = serendipity_db_update("staticblocks", array("id" => $this->staticblock["id"]), $this->staticblock);
if (is_string($result)) {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>';
if ($serendipity['version'][0] < 2) {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>'."\n";
} else {
echo '<div class="msg_error"><span class="icon-attention-circled"></span> ERROR: ' . $result . '</div>'."\n";
}
}
}
}
@ -411,11 +423,10 @@ class serendipity_event_includeentry extends serendipity_event
$limit_sql .= 'LIMIT ' . (int)$limit;
}
$q = "SELECT *
FROM {$serendipity['dbPrefix']}staticblocks
WHERE type = '" . $type . "'
ORDER BY $order
$limit_sql";
$q = "SELECT * FROM {$serendipity['dbPrefix']}staticblocks
WHERE type = '" . $type . "'
ORDER BY $order
$limit_sql";
if ($limit == 1) {
$blocks = serendipity_db_query($q, true, 'assoc', 1);
} else {
@ -429,12 +440,15 @@ class serendipity_event_includeentry extends serendipity_event
global $serendipity;
static $form = null;
$solidus = ($serendipity['version'][0] < 2) ? ' /' : '';
if ($form === null) {
$form = '<form action="serendipity_admin.php" method="post">';
$form .= '<div>';
$form .= ' <input type="hidden" name="serendipity[adminModule]" value="event_display" />';
$form .= ' <input type="hidden" name="serendipity[adminAction]" value="staticblocks" />';
$form .= '</div>';
$form = '
<form action="serendipity_admin.php" method="post">
<div>
<input type="hidden" name="serendipity[adminModule]" value="event_display"'.$solidus.'>
<input type="hidden" name="serendipity[adminAction]" value="staticblocks"'.$solidus.'>
</div>'."\n";
}
if ($type == 'form') {
@ -443,22 +457,23 @@ class serendipity_event_includeentry extends serendipity_event
$html = $form . '
<div>
<input type="hidden" name="serendipity[type]" value="' . $type . '" />
<input type="hidden" name="serendipity[type]" value="' . $type . '"'.$solidus.'>
<select id="staticblock_' . $type . '" name="serendipity[staticblock]">
<option value="__new">' . NEW_ENTRY . '</option>
<option value="__new">-----------------</option>';
$html .= $this->getPages($serendipity['POST']['staticblock'], $type);
$html .= ' </select><br />
<input class="serendipityPrettyButton input_button" type="submit" name="serendipity[staticSubmit]" value="' . GO . '" /> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[staticDelete]" value="' . DELETE . '" />';
$html .= '
</select><br'.$solidus.'>
<input class="serendipityPrettyButton input_button state_submit" type="submit" name="serendipity[staticSubmit]" value="' . GO . '" /> <input class="serendipityPrettyButton input_button state_cancel" type="submit" name="serendipity[staticDelete]" value="' . DELETE . '"'.$solidus.'>';
if ($type == 'template') {
$html .= '<br /><a onclick="this.href = this.href + document.getElementById(\'staticblock_template\').options[document.getElementById(\'staticblock_template\').selectedIndex].value" href="serendipity_admin.php?serendipity[adminModule]=entries&amp;serendipity[adminAction]=new&amp;serendipity[staticblock]=" style="margin-top: 5px; display: block" class="serendipityPrettyButton">' . STATICBLOCK_USE . '</a>';
$html .= '<br'.$solidus.'><a onclick="this.href = this.href + document.getElementById(\'staticblock_template\').options[document.getElementById(\'staticblock_template\').selectedIndex].value" href="serendipity_admin.php?serendipity[adminModule]=entries&amp;serendipity[adminAction]=new&amp;serendipity[staticblock]=" style="margin-top: 5px; display: block" class="serendipityPrettyButton">' . STATICBLOCK_USE . '</a>';
}
$html .= '
</div>
</form>';
</form>'."\n";
return $html;
}
@ -470,8 +485,8 @@ class serendipity_event_includeentry extends serendipity_event
if (empty($block['id'])) {
continue;
}
$html .= ' <option value="' . $block['id'] . '" ' . ($sel == $block['id'] ? 'selected="selected"' : '') . '>';
$html .= (function_exists('serendipity_specialchars') ? serendipity_specialchars($block['title']) : htmlspecialchars($block['title'], ENT_COMPAT, LANG_CHARSET)) . '</option>';
$html .= ' <option value="' . $block['id'] . '" ' . ($sel == $block['id'] ? 'selected="selected"' : '') . '>'."\n";
$html .= (function_exists('serendipity_specialchars') ? serendipity_specialchars($block['title']) : htmlspecialchars($block['title'], ENT_COMPAT, LANG_CHARSET)) . '</option>'."\n";
}
return $html;
@ -490,23 +505,23 @@ class serendipity_event_includeentry extends serendipity_event
if (empty($filename)) {
$filename = $this->staticblock['template'];
if (empty($filename)) $filename = $this->get_config('template', 'plugin_staticblock.tpl'); // case multi_block true, on fresh installs
}
$filename = basename($filename);
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile && $tfile != $filename) {
$tfile = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/' . $filename;
if (!file_exists($tfile)) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
if (serendipity_db_bool($this->staticblock['apply_markup'])) {
serendipity_plugin_api::hook_event('frontend_display', $this->staticblock);
}
$serendipity['smarty']->assign('staticblock', $this->staticblock);
$content = $serendipity['smarty']->fetch('file:'. $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
return $content;
}
@ -533,13 +548,21 @@ class serendipity_event_includeentry extends serendipity_event
}
}
echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />'. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '</div>';
if ($serendipity['versioon'][0] < 2) {
echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />'. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '</div>'."\n";
} else {
echo '<div class="msg_success"><span class="icon-ok-circled"></span> '. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '</div>'."\n";
}
$this->updateStaticBlock();
}
if (!empty($serendipity['POST']['staticDelete']) && $serendipity['POST']['staticblock'] != '__new') {
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}staticblocks WHERE id = " . (int)$serendipity['POST']['staticblock']);
echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />'. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '</div>';
if ($serendipity['versioon'][0] < 2) {
echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />'. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '</div>'."\n";
} else {
echo '<div class="msg_success"><span class="icon-ok-circled"></span> '. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '</div>'."\n";
}
}
echo '<table align="center">
@ -553,11 +576,13 @@ class serendipity_event_includeentry extends serendipity_event
<td style="text-align: center; vertical-align: top">' . $this->showBlockForm('template') . '</td>
<td style="text-align: center; vertical-align: top">' . $this->showBlockForm('block') . '</td>
</tr>
</table>';
</table>'."\n\n";
$solidus = ($serendipity['version'][0] < 2) ? ' /' : '';
/* SHOW SELECTION */
echo $this->showBlockForm('form');
echo '<div>';
if ($serendipity['POST']['staticSubmit']) {
echo '<h2>';
if ($serendipity['POST']['type'] == 'template') {
@ -565,16 +590,18 @@ class serendipity_event_includeentry extends serendipity_event
} else {
echo STATICBLOCK_EDIT_BLOCKS;
}
echo '</h2>';
echo '</h2>'."\n\n";
echo '<div>'."\n";
echo ' <input type="hidden" name="serendipity[staticSave]" value="true"'.$solidus.'>'."\n";
echo ' <input type="hidden" name="serendipity[staticblock]" value="' . $serendipity['POST']['staticblock'] . '"'.$solidus.'>'."\n";
echo ' <input type="hidden" name="serendipity[type]" value="' . $serendipity['POST']['type'] . '"'.$solidus.'>'."\n";
echo '</div>'."\n\n";
echo '<input type="hidden" name="serendipity[staticSave]" value="true" />';
echo '<input type="hidden" name="serendipity[staticblock]" value="' . $serendipity['POST']['staticblock'] . '" />';
echo '<input type="hidden" name="serendipity[type]" value="' . $serendipity['POST']['type'] . '" />';
$this->showForm($serendipity['POST']['type']);
}
echo '</form>';
echo '</div>';
echo '</form>'."\n";
}
function addProperties(&$properties, &$eventData) {
@ -739,10 +766,10 @@ class serendipity_event_includeentry extends serendipity_event
$attach_block = '';
}
?>
<fieldset style="margin: 5px">
<legend><?php echo STATICBLOCK_ATTACH; ?></legend>
<div>
<select name="serendipity[properties][attach_block]">
<fieldset id="edit_entry_staticblock" class="entryproperties_staticblock" style="<?php echo ($serendipity['version'][0] > 1) ? 'margin: 1em 0' : 'margin: 5px'; ?>">
<span class="wrap_legend"><legend><?php echo STATICBLOCK_ATTACH; ?></legend></span>
<div style="margin-top: 0.5em">
<select id="attach_static_block" name="serendipity[properties][attach_block]">
<option value=""></option>
<?php echo $this->getPages($attach_block); ?>
</select>