From 8cebd6ddf40b8aabe92b3bf0a6ef37d358824c8f Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 1 Jun 2015 13:24:48 +0200 Subject: [PATCH] update includeentry plugin --- serendipity_event_includeentry/ChangeLog | 9 + .../UTF-8/lang_de.inc.php | 4 +- serendipity_event_includeentry/form.inc.php | 134 +++++------ .../lang_de.inc.php | 4 +- .../oldform.inc.php | 226 ++++++++++++++++++ .../plugin_staticblock.tpl | 2 +- .../serendipity_event_includeentry.php | 129 ++++++---- 7 files changed, 372 insertions(+), 136 deletions(-) create mode 100644 serendipity_event_includeentry/oldform.inc.php diff --git a/serendipity_event_includeentry/ChangeLog b/serendipity_event_includeentry/ChangeLog index f3de554a..2967ce49 100644 --- a/serendipity_event_includeentry/ChangeLog +++ b/serendipity_event_includeentry/ChangeLog @@ -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']; diff --git a/serendipity_event_includeentry/UTF-8/lang_de.inc.php b/serendipity_event_includeentry/UTF-8/lang_de.inc.php index 9e1ab0c6..1b4b8eec 100644 --- a/serendipity_event_includeentry/UTF-8/lang_de.inc.php +++ b/serendipity_event_includeentry/UTF-8/lang_de.inc.php @@ -1,4 +1,4 @@
- + +
+ get('type')) { case 'seperator': ?> -
- - +
get('select_values'); ?> - - - - + + - - - - + + + - - - - +
+
+ + + +
+
- - - - - - +
+ + + +
+ 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': - ?> +
+ get('default'); ?> +
+ +
+ +
+ @@ -219,8 +192,9 @@ } } ?> -

- -
  - -
-
- 0)) ? "size='{$select_size}'" : ''}> $select_desc) { $id = (function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET)); ?> - + - -
-
- -
  - -
+ class="has_info"> + + +
$radio_value) { @@ -125,75 +106,71 @@ if ($counter == 1) { ?> -
+
- title="" /> - + title=""> + -
+
-
- -
  -
-
- -
-
-    -
-
- -
-
get('default'); ?>
-
-
- + +
+
+ +
diff --git a/serendipity_event_includeentry/lang_de.inc.php b/serendipity_event_includeentry/lang_de.inc.php index 2201d83e..0f680ef5 100644 --- a/serendipity_event_includeentry/lang_de.inc.php +++ b/serendipity_event_includeentry/lang_de.inc.php @@ -1,4 +1,4 @@
+ +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': +?> + + + +get('select_values'); +?> + + + + + 0) { + $radio = $cbag->get('radio'); + } + + if (empty($per_row)) { + $per_row = $cbag->get('radio_per_row'); + if (empty($per_row)) { + $per_row = 2; + } + } +?> + + + + + + + + + + + + + + + + + +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': + ?> 0) { + $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); + serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); + + if ($ev['skip_nuggets'] === false) { +?> + + +

+ +
  + +
+
+ +
+
+ +
  + +
+ $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) { +?> +
+ + title="" /> + + +
+ +
+ +
  +
+
+ +
+
+    +
+
+ +
+
get('default'); ?>
+
+
+ +
diff --git a/serendipity_event_includeentry/plugin_staticblock.tpl b/serendipity_event_includeentry/plugin_staticblock.tpl index 7fc115c0..3bac4380 100644 --- a/serendipity_event_includeentry/plugin_staticblock.tpl +++ b/serendipity_event_includeentry/plugin_staticblock.tpl @@ -1,7 +1,7 @@

{$staticblock.timestamp|@formatTime:DATE_FORMAT_ENTRY}

{$staticblock.title}

- +
{$staticblock.body}
{$staticblock.extended}
diff --git a/serendipity_event_includeentry/serendipity_event_includeentry.php b/serendipity_event_includeentry/serendipity_event_includeentry.php index 2d3cca1b..a802f904 100644 --- a/serendipity_event_includeentry/serendipity_event_includeentry.php +++ b/serendipity_event_includeentry/serendipity_event_includeentry.php @@ -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 = '' . CATEGORIES . '
'; + $html = (($serendipity['version'][0] < 2) ? '' . CATEGORIES . '
' : '' . CATEGORIES . '') ."\n"; $all_valid = false; if (is_array($serendipity['POST']['plugin']['enabled_categories'])) { @@ -253,16 +253,16 @@ class serendipity_event_includeentry extends serendipity_event } } - $html .= ''."\n"; + $html .= ' '."\n"; if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ( $cats as $cat ) { - $html .= '' . "\n"; + $html .= ' ' . "\n"; } } - $html .= ''; + $html .= ''."\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 '
ERROR: ' . $result . '
'; + if ($serendipity['version'][0] < 2) { + echo '
ERROR: ' . $result . '
'."\n"; + } else { + echo '
ERROR: ' . $result . '
'."\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 '
ERROR: ' . $result . '
'; + if ($serendipity['version'][0] < 2) { + echo '
ERROR: ' . $result . '
'."\n"; + } else { + echo '
ERROR: ' . $result . '
'."\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 .= '
'; - $form .= ' '; - $form .= ' '; - $form .= '
'; + $form = ' + +
+ + +
'."\n"; } if ($type == 'form') { @@ -443,22 +457,23 @@ class serendipity_event_includeentry extends serendipity_event $html = $form . '
- +
- '; + $html .= ' + + '; if ($type == 'template') { - $html .= '
' . STATICBLOCK_USE . ''; + $html .= '' . STATICBLOCK_USE . ''; } $html .= '
-
'; + '."\n"; return $html; } @@ -470,8 +485,8 @@ class serendipity_event_includeentry extends serendipity_event if (empty($block['id'])) { continue; } - $html .= ' '; + $html .= ' '."\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 '
'. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '
'; + if ($serendipity['versioon'][0] < 2) { + echo '
'. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '
'."\n"; + } else { + echo '
'. DONE . ': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')). '
'."\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 '
'. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '
'; + if ($serendipity['versioon'][0] < 2) { + echo '
'. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '
'."\n"; + } else { + echo '
'. DONE .': '. sprintf(RIP_ENTRY, $this->staticblock['title']) . '
'."\n"; + } } echo ' @@ -553,11 +576,13 @@ class serendipity_event_includeentry extends serendipity_event -
' . $this->showBlockForm('template') . ' ' . $this->showBlockForm('block') . '
'; + '."\n\n"; + + $solidus = ($serendipity['version'][0] < 2) ? ' /' : ''; /* SHOW SELECTION */ echo $this->showBlockForm('form'); - echo '
'; + if ($serendipity['POST']['staticSubmit']) { echo '

'; if ($serendipity['POST']['type'] == 'template') { @@ -565,16 +590,18 @@ class serendipity_event_includeentry extends serendipity_event } else { echo STATICBLOCK_EDIT_BLOCKS; } - echo '

'; + echo ''."\n\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo ' '."\n"; + echo ' '."\n"; + echo '
'."\n\n"; - echo ''; - echo ''; - echo ''; $this->showForm($serendipity['POST']['type']); } - echo ''; - echo '
'; + echo ''."\n"; } function addProperties(&$properties, &$eventData) { @@ -739,10 +766,10 @@ class serendipity_event_includeentry extends serendipity_event $attach_block = ''; } ?> -
- -
- getPages($attach_block); ?>