diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d36aa4..7db04b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +# Under development: [FlatPress 1.3](https://github.com/flatpressblog/flatpress/releases/tag/1.3) +## General +- Added [SECURITY.md](https://github.com/flatpressblog/flatpress/blob/master/SECURITY.md) +- [README](https://github.com/flatpressblog/flatpress/blob/master/README.md): added "help and support" section + +## Plugins +- Gallery captions plugin added (see [#108](https://github.com/flatpressblog/flatpress/issues/108)) +- PhotoSwipe plugin added (see [#109](https://github.com/flatpressblog/flatpress/issues/109)) +- jQuery plugin: Updated jQuery (3.5.1 => 3.6) and jQueryUI (1.12.1 => 1.13) + +## Themes +- Leggero theme: Fixed searchbox glitch in FlatMaas revisited style (see [#97](https://github.com/flatpressblog/flatpress/issues/97)) +- Leggero theme: Fixed missing bullets in preview (see [#98](https://github.com/flatpressblog/flatpress/issues/98)) +- Leggero theme: CSS of the Leggero style had some glitches on mobile devices +- Leggero theme: Invalid HTML output fixed (see [#106](https://github.com/flatpressblog/flatpress/issues/106)) + +## Bugfixes +- Comment Center config page threw errors (see [#90](https://github.com/flatpressblog/flatpress/issues/90)) +- Fixed glitches in Spanish an Portuguese language files +- Plugin management page: Removed empty warning messages box +- Fixed wrong pt-br country code (see [#100](https://github.com/flatpressblog/flatpress/issues/100)) +- Fixed error at prev link on first / next link on last entry (see [#95](https://github.com/flatpressblog/flatpress/issues/95)) + +## Security +- Fixed security issue reported by huntr.dev: Session cookie missed the "secure" flag + # 2021-06-19: [FlatPress 1.2.1](https://github.com/flatpressblog/flatpress/releases/tag/1.2.1) ## Bugfixes - BOM in French language files lead to blank page in admin area (see [#82](https://github.com/flatpressblog/flatpress/issues/82)) diff --git a/admin/admin-inline.tpl b/admin/admin-inline.tpl index 648f24a..926b8e2 100644 --- a/admin/admin-inline.tpl +++ b/admin/admin-inline.tpl @@ -1,4 +1,4 @@ - + {$flatpress.title}{$pagetitle} diff --git a/admin/index.php b/admin/index.php index db0b4f9..eeee52f 100755 --- a/admin/index.php +++ b/admin/index.php @@ -1,10 +1,9 @@ - + FlatPress diff --git a/admin/panels/entry/admin.entry.commentlist.tpl b/admin/panels/entry/admin.entry.commentlist.tpl index 4ba3b5d..c7476d1 100755 --- a/admin/panels/entry/admin.entry.commentlist.tpl +++ b/admin/panels/entry/admin.entry.commentlist.tpl @@ -13,7 +13,7 @@ {html_form} - + * echo ' * '; * * } @@ -105,7 +105,9 @@ class admin_plugin_default extends AdminPanelAction { function main() { // $conf = io_load_file(CONFIG_DIR . 'plugins.conf.php'); - $this->smarty->assign('warnings', $this->errors); + if (!empty($this->errors)) { + $this->smarty->assign('warnings', $this->errors); + } $this->smarty->assign('enabledlist', $this->fp_plugins); lang_load('admin.plugin'); diff --git a/admin/panels/widgets/admin.widgets.default.php b/admin/panels/widgets/admin.widgets.default.php index d3b60cf..5c58d85 100644 --- a/admin/panels/widgets/admin.widgets.default.php +++ b/admin/panels/widgets/admin.widgets.default.php @@ -1,124 +1,107 @@ '; - } - add_action('wp_footer', 'admin_widgets_head'); - - - class admin_widgets_default extends AdminPanelAction { - - //var $validators = array(array('content', 'content', 'notEmpty', false, false)); - var $events = array('save'); - - - function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) { - - if (!isset($wlist[$wpos])) - return; - - $widget_list[$wpos] = array(); - - foreach($wlist[$wpos] as $idx => $wdg) { - - $widget_list[$wpos][$idx] = array(); - - $newid = $wdg; # @list($newid, $params) = explode(":", $wdg); - - $widget_list[$wpos][$idx]['id'] = $newid; - - - if (isset($registered_w[$newid])){ - $thiswdg = $registered_w[$newid]; - - $widget_list[$wpos][$idx]['name'] = $thiswdg['name']; - - if ($thiswdg['nparams'] > 0) { - $widget_list[$wpos][$idx]['params'] = $params; - } - - /* - * here should go the check for - * limited parameters: parameters limited to a - * particular set would mean using a control + * in the template + * + */ + } else { + + global $lang; + + $widget_list [$wpos] [$idx] ['name'] = $newid; + $widget_list [$wpos] [$idx] ['class'] = 'errors'; + + $errs = sprintf($lang ['admin'] ['widgets'] ['errors'] ['generic'], $newid); + $this->smarty->append('warnings', $errs); } - - $oldwidget_list = array(); - foreach($wlist as $wpos => $c){ - $this->get_widget_lists($wlist, $wpos, $oldwidget_list, $registered_w, false); - } - - $this->smarty->assign('widgetlist', $widget_list); - $this->smarty->assign('oldwidgetlist', $oldwidget_list); - - - $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php'); - - $this->smarty->assign('pluginconf', $conf); - - return 0; - - } - - function onsave() { - - $fp_widgets = isset($_POST['widgets'])? $_POST['widgets'] : array(); - $success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets')); - - $this->smarty->assign('success', ( $success )? 1 : -1 ); - - return PANEL_REDIRECT_CURRENT; - - } - + if (!$widget_list [$wpos] && !$add_empties) + unset($widget_list [$wpos]); } + + function main() { + lang_load('admin.widgets'); + // $this->smarty->assign('warnings', admin_widgets_checkall()); + global $fp_widgets; + + $registered_w = get_registered_widgets(); + $registered_ws = get_registered_widgetsets(null); + $this->smarty->assign('fp_registered_widgets', $registered_w); + + $wlist = $fp_widgets->getList(); + $widget_list = array(); + + foreach ($registered_ws as $wpos) { + + $widget_list [$wpos] = array(); + + $this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true); + + unset($wlist [$wpos]); + } + + $oldwidget_list = array(); + foreach ($wlist as $wpos => $c) { + $this->get_widget_lists($wlist, $wpos, $oldwidget_list, $registered_w, false); + } + + $this->smarty->assign('widgetlist', $widget_list); + $this->smarty->assign('oldwidgetlist', $oldwidget_list); + + $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php'); + + $this->smarty->assign('pluginconf', $conf); + + return 0; + } + + function onsave() { + $fp_widgets = isset($_POST ['widgets']) ? $_POST ['widgets'] : array(); + $success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets')); + + $this->smarty->assign('success', ($success) ? 1 : -1); + + return PANEL_REDIRECT_CURRENT; + } + +} ?> diff --git a/fp-defaults/plugins.conf.php b/fp-defaults/plugins.conf.php index 01b7891..c17b56a 100755 --- a/fp-defaults/plugins.conf.php +++ b/fp-defaults/plugins.conf.php @@ -28,5 +28,7 @@ $fp_plugins = array( 'readmore', 'favicon', 'commentcenter', - 'mediamanager' + 'mediamanager', + 'gallerycaptions', + 'photoswipe' ); \ No newline at end of file diff --git a/fp-includes/core/core.gallery.php b/fp-includes/core/core.gallery.php new file mode 100644 index 0000000..2faaa22 --- /dev/null +++ b/fp-includes/core/core.gallery.php @@ -0,0 +1,140 @@ +getlist(); + foreach ($l as $i => $f) { + // remove caption files + if ($f === GALLERY_CAPTIONS_FILENAME || $f === GALLERY_CAPTIONS_LEGACYFILENAME) { + array_splice($l, $i, 1); + } + } + sort($l); + return $l; +} + +/** + * Reads the captions from the given gallery directory. + * + * @param string $galleryDir + * the gallery dir, e.g. 'images/NameOfTheGallery' + * @return array the gallery captions as associative array { filename => caption } + */ +function gallery_read_captions($galleryDir) { + $captions = array(); + + $captionsFileContent = null; + $galleryDirPathAbs = ABS_PATH . FP_CONTENT . $galleryDir . '/'; + // read captions.conf from gallery dir + if (file_exists($galleryDirPathAbs . GALLERY_CAPTIONS_FILENAME)) { + $captionsFileContent = file($galleryDirPathAbs . GALLERY_CAPTIONS_FILENAME); + } // + // legacy mode: if captions.conf is not available, check for texte.conf + elseif (file_exists($galleryDirPathAbs . GALLERY_CAPTIONS_LEGACYFILENAME)) { + $captionsFileContent = file($galleryDirPathAbs . GALLERY_CAPTIONS_LEGACYFILENAME); + } // + // no caption file available + else { + return array(); + } + + // read captions file line by line + foreach ($captionsFileContent as $currentline) { + // image file name is before of the '=' character, ... + $image = trim(substr($currentline, 0, strpos($currentline, '='))); + // ... the caption after. + $caption = trim(substr($currentline, (strpos($currentline, '=') + 1))); + // $captions [$image] = htmlentities($descript); + $captions [$image] = $caption; + } + return $captions; +} + +/** + * Stores the given captions for the given gallery + * + * @param string $galleryName + * the gallery dir, e.g. 'NameOfTheGallery' + * @param array $captions + * the gallery captions as associative array { filename => caption } + * @return boolean true if captions were written successfully; false otherwise + */ +function gallery_write_captions($galleryName, $captions) { + $gallerydirPath = IMAGES_DIR . $galleryName; + if (!file_exists($gallerydirPath)) { + return false; + } + $captionfilePath = IMAGES_DIR . $galleryName . DIRECTORY_SEPARATOR . GALLERY_CAPTIONS_FILENAME; + $captionfileHandle = fopen($captionfilePath, 'w'); + + $filecontent = ''; + foreach ($captions as $filename => $caption) { + $filecontent .= $filename . ' = ' . $caption . PHP_EOL; + } + + fwrite($captionfileHandle, $filecontent); + fclose($captionfileHandle); + + // Updating from legacy versions: If legacy captions fill still exists, delete if + $legacyCaptionfilePath = IMAGES_DIR . $galleryName . DIRECTORY_SEPARATOR . GALLERY_CAPTIONS_LEGACYFILENAME; + if (file_exists($legacyCaptionfilePath)) { + unlink($legacyCaptionfilePath); + } + return true; +} \ No newline at end of file diff --git a/fp-includes/core/core.wp-pluggable-funcs.php b/fp-includes/core/core.wp-pluggable-funcs.php index 1e1957e..815e020 100755 --- a/fp-includes/core/core.wp-pluggable-funcs.php +++ b/fp-includes/core/core.wp-pluggable-funcs.php @@ -46,7 +46,8 @@ if (!function_exists('get_nextpage_link')) : $a = _get_nextprev_link('NextPage'); - if ($q->single) { + // show next entry link only if there actually is a next entry - and only if one single entry is displayed + if (isset($a) && $q->single) { $a [0] .= ' » '; } @@ -62,7 +63,8 @@ if (!function_exists('get_prevpage_link')) : $a = _get_nextprev_link('PrevPage'); - if ($q->single) { + // show previous entry link only if there actually is a previous entry - and only if one single entry is displayed + if (isset($a) && $q->single) { $a [0] = ' « ' . $a [0]; } diff --git a/fp-includes/core/includes.php b/fp-includes/core/includes.php index 2fbeb24..13800ea 100755 --- a/fp-includes/core/includes.php +++ b/fp-includes/core/includes.php @@ -40,5 +40,6 @@ require_once INCLUDES_DIR . 'core.system.php'; require_once INCLUDES_DIR . 'core.theme.php'; // require_once INCLUDES_DIR.'core.layout.php'; require_once INCLUDES_DIR . 'core.users.php'; +require_once INCLUDES_DIR . 'core.gallery.php'; ?> diff --git a/fp-interface/lang/pt-br/lang.conf.php b/fp-interface/lang/pt-br/lang.conf.php index 866e3e6..ae0e64d 100644 --- a/fp-interface/lang/pt-br/lang.conf.php +++ b/fp-interface/lang/pt-br/lang.conf.php @@ -1,10 +1,9 @@ diff --git a/fp-interface/themes/leggero/cpheader.tpl b/fp-interface/themes/leggero/cpheader.tpl index 01d74b1..683353b 100644 --- a/fp-interface/themes/leggero/cpheader.tpl +++ b/fp-interface/themes/leggero/cpheader.tpl @@ -1,4 +1,4 @@ - + {$flatpress.title}{$pagetitle} diff --git a/fp-interface/themes/leggero/entry-default.tpl b/fp-interface/themes/leggero/entry-default.tpl index ee872f9..b58ab06 100644 --- a/fp-interface/themes/leggero/entry-default.tpl +++ b/fp-interface/themes/leggero/entry-default.tpl @@ -12,9 +12,9 @@ {include file="shared:entryadminctrls.tpl"} - +
{$content|tag:the_content} - +