
commit a4711e7017e918d3568c3eeaa1f91281e559fd58 Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Aug 21 00:41:09 2023 +0200 other small adjustments - BBcode-Facebook-Viedo now uses the latest video player API and the lazy loading mechanism of the browser - Added background-attachment: fix workaround for mobile devices - small fixes to be valid with CSS3 commit 00c0e3740349996823fb31ec80be79dceccae61d Author: Fraenkiman <frank.pcn@gmail.com> Date: Fri Aug 18 20:14:05 2023 +0200 Update plugin.bbcode.php - BBcode-Facebook-Viedo now uses the latest video player API and the lazy loading mechanism of the browser commit d8688ab2f22a855461142b4533cffd553d6283ee Author: Fraenkiman <frank.pcn@gmail.com> Date: Fri Aug 18 00:18:19 2023 +0200 Update plugin.fpprotect.php - FP-Protect allows full-screen playback of embedded videos commit b4ccc4a021e6437db0c78ceebe2d257760ebe454 Author: Fraenkiman <frank.pcn@gmail.com> Date: Tue Aug 15 23:46:57 2023 +0200 Update common.css - center BBcode video if screen < 960px commit ff3f9d84708f774736bf29ebdf0c5f34c6c8936a Author: Fraenkiman <frank.pcn@gmail.com> Date: Sat Aug 12 13:31:51 2023 +0200 Update common.css - BBcode video is displayed larger on larger screens commit 9c2235729a7b34c640a55b7d0c075a36bac567dd Author: Fraenkiman <frank.pcn@gmail.com> Date: Tue Aug 8 00:54:31 2023 +0200 Update admin.css - now also fits the entry preview on a smartphone commit b531da308131482dc355525daec5b4ea8e640542 Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Aug 7 23:41:45 2023 +0200 Squashed commit of the following: commit b8c94ecac23abec830543ad9e928e62d0e02d96d Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Aug 7 23:23:21 2023 +0200 Media queries were created for individual device classes - Media queries were created for individual device classes (smartphone, netbook, laptop and PC) in order to commit e2258bf4b52212074d98d08c65f7b62989478ade Author: Fraenkiman <frank.pcn@gmail.com> Date: Thu Aug 3 00:16:22 2023 +0200 Use full width on small screens Mobile devices are increasingly replacing the classic PC. So it is all the more important to make the theme and the administration area more accessible for today's mobile devices. - With a screen width of up to 768px, the full width is utilized. - The theme is no longer compressed vertically on small screens from 720px to 768px. commit ff76513e2b8b8ada1bc4dc2b395911e3f6c0f95e Author: Fraenkiman <frank.pcn@gmail.com> Date: Wed Aug 2 00:13:36 2023 +0200 Update admin.css commit 8140761f7fa1dde2395bee101e2df16332f5ff08 Author: Fraenkiman <frank.pcn@gmail.com> Date: Tue Aug 1 01:03:39 2023 +0200 the minimum width removed from the body-container - the minimum width removed from the body-container entirely commit eb651c586dd0401a1edceb5ef2e867003692f8cd Author: Fraenkiman <frank.pcn@gmail.com> Date: Tue Aug 1 00:15:30 2023 +0200 reduced the minimum width to 720px - reduced the minimum width to 720px for better viewing with a mobile device in landscape mode commit 2ce9fc605ebb83c43e49ce15ecb531695c10dbd6 Author: Fraenkiman <frank.pcn@gmail.com> Date: Sun Jul 30 18:57:11 2023 +0200 Fixes a problem in the admin area when rendering font-sizes - Fixes a problem in the admin panel when displaying font sizes in the mobile version of Firefox and Chrome. commit c8d4ee702791591d3557c51ef457c7bd9bad4d2d Author: Fraenkiman <frank.pcn@gmail.com> Date: Sun Jul 30 18:25:02 2023 +0200 Fixes a problem in the admin area when rendering font-sizes Fixes a problem in the admin panel when displaying font sizes in the mobile version of Firefox and Chrome. commit 451a960dc9543cac5ebbbe51d4084b85e86ca2b7 Author: Fraenkiman <frank.pcn@gmail.com> Date: Sat Jul 29 03:08:33 2023 +0200 Removes obsolete acronym element, Fixes a problem when rendering font-sizes in Safari - Removes obsolete acronym element in the language files and replaces it with the appr element - Fixes a problem in the admin area when rendering font-sizes in Safari (iPhone/iPad). #256 The Safari version used in iOS (iPhone/iPad) sometimes "ignores" the font sizes defined with font-size when rendering web pages or adjusts them automatically to improve readability. In certain places this is not bad, but it can also lead to unattractive changes in the design of the admin area. commit a844073bdb2e199ec1338f2b7fea27422c167db6 Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Jul 24 00:21:37 2023 +0200 Update common.css - Width of comment and contact text field defined commit 5c3cc4348ced03d319c72477c8a660ac4bc4632f Author: Fraenkiman <frank.pcn@gmail.com> Date: Wed Jul 19 01:16:39 2023 +0200 Fixed more CSS/Glitches - Vertical alignment of the BBcode toolbar - placed missing label elements in config panel for consistent alignment commit fec38755ba9929a0c5dfc614757ee8df7393d351 Author: Fraenkiman <frank.pcn@gmail.com> Date: Sat Jul 15 17:59:31 2023 +0200 Update admin.css - fixed vertical alignment of BBCode toolbar in write panel commit ef13f5488fdc48efe2101fe6f1e35a103ff08b1d Author: Fraenkiman <frank.pcn@gmail.com> Date: Fri Jul 14 00:25:50 2023 +0200 Configuration panel revised - In the admin area, the configuration panel has been revised commit 54232c3dd325027926ea78592e007475798d1fd0 Author: Fraenkiman <frank.pcn@gmail.com> Date: Tue Jul 11 21:57:18 2023 +0200 PhotoSwipe 4.1.3 included This upgrades PhotoSwipe to the January 8, 2019 release level and is the last version before rewriting to ES6. Fixed the following: Fixes an issue with devices that have multiple input types and PhotoSwipe does not wipe. Fixes an issue where the layout does not update after an alignment change in some cases. Previous FlatPress-specific fixes have been considered and incorporated. Details can be found here: https://github.com/dimsemenov/PhotoSwipe/releases With best regards Frank commit 1179f307ffa0c8b27fe10ccb47a4dfce516a1bf2 Merge: b735135 1aab02c Author: Frank Hochmuth <frank.pcn@gmail.com> Date: Mon Jul 10 01:29:20 2023 +0200 Merge branch 'master' into upstream/makup-Leggero-Theme commit b735135a7f5911c34eee4e01b4ef56db95d6ac06 Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Jul 10 01:12:32 2023 +0200 Fresh makeup for Leggero-v2 style This elevates the Leggero-v2 style to a more modern design. In most situations in life, first impressions count. The FlatPress Leggero-v2 style is what the user sees first after performing the setup. Potential new users may not immediately find their way to the wiki to see the variety of themes there - and hastily delete FlatPress again. Therefore I made a few small changes to the style: - Adjusted the alignment of the calendar widget and the search widget. - A single PhotoSwipe image or a whole gallery is now centered in the responsive design. #150 - BBcode videos are no longer chopped off in responsive design, but adjusted to the width and center aligned. - The overall appearance is now not so angular/edgy. - A BBcode embedded Facebook video now has localized languages with language tag. #252 (https://developers.facebook.com/docs/javascript/internationalization). - BBcode: Removed reference to an active lightbox plugin, as PhotoSwipe can be used as an alternative. - Fixed an error in the HTML code of PhotoSwipe-Plugin. #253 - Lucida Console [code] ... [/code]is now correct as a font in the CSS file. - Admin area now has Leggero-v2 style background instead of white background. With best regards Frank commit f8c66f5c0b8527cc0913f85b5a10ee2e7b673d74 Author: Fraenkiman <frank.pcn@gmail.com> Date: Mon Jul 3 01:20:07 2023 +0200 Fresh makeup for Leggero-v2 Style This elevates the style Leggero-v2 to a more modern looking design. Details: * IE compatibility removed * fixed some minor layout/CSS glitches * a single photoswipe image or a whole gallery is now centered in RESPONSIVE DESIGN. * The appearance is now not so canny and has been adapted to the body.
309 lines
11 KiB
PHP
309 lines
11 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Static functions for the plugin.
|
|
*/
|
|
class PhotoSwipeFunctions {
|
|
|
|
/**
|
|
* Class-wide flag that the PhotoSwipe overlay UI has already been initialized
|
|
*
|
|
* @var boolean
|
|
*/
|
|
private static $photoswipeUiIsInitialized = false;
|
|
|
|
/**
|
|
* Class-wide index counter for the shown images
|
|
*
|
|
* @var int
|
|
*/
|
|
private static $lastusedDataIndex = 0;
|
|
|
|
/**
|
|
* Callback function called for [img] tags which returns the HTML code for a single PhotoSwipe image.
|
|
*
|
|
* @param string $action
|
|
* @param array $attr
|
|
* the attributes given in the tag
|
|
* @param string $content
|
|
* @param array $params
|
|
* @param string $node_object
|
|
* @return boolean|string the HTML code for a single PhotoSwipe image
|
|
*/
|
|
static function getImageHtml($action, $attr, $content, $params, $node_object) {
|
|
global $lang;
|
|
|
|
if ($action == 'validate') {
|
|
// not used for now
|
|
return true;
|
|
}
|
|
|
|
// the name of the image - and its relative path
|
|
$img = $attr ['default'];
|
|
|
|
// sanitize first
|
|
if (strpos($img, '..') !== false) {
|
|
return $lang ['plugin'] ['photoswipe'] ['label_imagedoesntexist'];
|
|
}
|
|
$imgPathRel = 'fp-content/' . $img;
|
|
$imgUrl = BLOG_BASEURL . 'fp-content/' . $img;
|
|
|
|
// check if dir exists
|
|
if (!file_exists($imgPathRel)) {
|
|
return $lang ['plugin'] ['photoswipe'] ['label_imagedoesntexist'] . ' ' . $img;
|
|
}
|
|
|
|
// image title will be its file name - or the title from the tag attributes, if given
|
|
$title = isset($attr ['title']) ? $attr ['title'] : '';
|
|
// for usage in HTML attributes, we need to remove quotes and HTML tags from the title
|
|
$titleForAttributes = isset($attr ['title']) ? htmlentities(strip_tags($attr ['title'])) : '';
|
|
|
|
// image may float, according the the given float attribute - if not given, use "nofloat" class
|
|
$floatClasses = 'thumbnail nofloat';
|
|
if (isset($attr ['float'])) {
|
|
$floatClasses = 'float' . $attr ['float'];
|
|
}
|
|
|
|
// to get the HTML code for preview image, we use the Flatpress standard function do_bbcode_img()
|
|
$attr ['title'] = $titleForAttributes;
|
|
$previewHtml = do_bbcode_img(null, $attr, null, null, null);
|
|
// but: we don't need the popup link surrounding the resulting <img> tag
|
|
$matches = null;
|
|
preg_match('/<img[^>]*/u', $previewHtml, $matches);
|
|
$previewHtml = $matches [0];
|
|
if ($previewHtml [strlen($previewHtml) - 1] === '/') {
|
|
$previewHtml = substr($previewHtml, 0, strlen($previewHtml) - 1);
|
|
}
|
|
// add some additional attributes to the <img> tag and close it properly
|
|
$previewHtml .= ' itemprop="thumbnail" title="' . $titleForAttributes . '">';
|
|
|
|
// PhotoSwipe needs to know the dimensions of the image - so we read them
|
|
$imgsize = @getimagesize($imgPathRel);
|
|
$datasizeAttr = ($imgsize === false) ? '' : 'data-size="' . $imgsize [0] . 'x' . $imgsize [1] . '" ';
|
|
|
|
// set max width of the figure according to the width attribute
|
|
$styleAttr = isset($attr ['width']) ? ' style="width:' . $attr ['width'] . 'px" ' : '';
|
|
|
|
// now lets assemble the whole HTML code - including the overlay HTML, if not inserted into the DOM before
|
|
$imgHtml = self::getPhotoSwipeOverlay() . //
|
|
'<div ' . //
|
|
'class="photoswipe ' . $floatClasses . '"' . $styleAttr . //
|
|
'itemscope itemtype="http://schema.org/ImageGallery"' . //
|
|
'>' . //
|
|
'<figure ' . //
|
|
'itemprop="associatedMedia" ' . //
|
|
'itemscope ' . //
|
|
'itemtype="http://schema.org/ImageObject" ' . //
|
|
'data-index="' . self::$lastusedDataIndex . '" ' . //
|
|
'class="' . $floatClasses . '" ' . //
|
|
'>' . //
|
|
'<a ' . //
|
|
'href="' . $imgUrl . '" ' . //
|
|
'itemprop="contentUrl" ' . //
|
|
$datasizeAttr . //
|
|
'data-index="' . self::$lastusedDataIndex . '" ' . //
|
|
'title="' . htmlentities($title) . '" ' . //
|
|
'>' . //
|
|
$previewHtml . //
|
|
'</a>' . //
|
|
'<figcaption' . $styleAttr . '>' . $title . '</figcaption>' . //
|
|
'</figure>' . //
|
|
'</div>';
|
|
|
|
self::$lastusedDataIndex++;
|
|
return $imgHtml;
|
|
}
|
|
|
|
/**
|
|
* Callback function called for [gallery] tags which returns the HTML code for a PhotoSwipe gallery.
|
|
*
|
|
* @param string $action
|
|
* @param array $attr
|
|
* the attributes given in the tag
|
|
* @param string $content
|
|
* @param array $params
|
|
* @param string $node_object
|
|
* @return boolean|string the HTML code for a PhotoSwipe gallery
|
|
*/
|
|
static function getGalleryHtml($action, $attr, $content, $params, $node_object) {
|
|
global $lang;
|
|
if ($action == 'validate') {
|
|
// not used for now
|
|
return true;
|
|
}
|
|
|
|
// gallery dir is set as tag attribute
|
|
$dir = $attr ['default'];
|
|
|
|
// sanitize first
|
|
if (strpos($dir, '..') !== false) {
|
|
return $lang ['plugin'] ['photoswipe'] ['label_gallerydoesntexist'];
|
|
}
|
|
// check if dir exists
|
|
if (!file_exists("fp-content/" . $dir)) {
|
|
return $lang ['plugin'] ['photoswipe'] ['label_gallerydoesntexist'] . ' ' . $dir;
|
|
}
|
|
// force slash at the end
|
|
if (substr($dir, -1) != '/') {
|
|
$dir .= '/';
|
|
}
|
|
|
|
// read images from gallery directory
|
|
$imagefiles = gallery_read_images($dir);
|
|
|
|
// read image caption from captions file (if existant in the gallery directory)
|
|
$captions = gallery_read_captions($dir);
|
|
|
|
// call getImageHtml() to get the image's HTML code for each image in the gallery dir
|
|
$imgattr = $attr;
|
|
$str = '<div class="img-gallery ' . sanitize_title($dir) . '">';
|
|
foreach ($imagefiles as $f) {
|
|
// set the image's caption as title attribut of the img tag
|
|
$imgattr ['default'] = $dir . $f;
|
|
$imgattr ['title'] = array_key_exists($f, $captions) ? $captions [$f] : '';
|
|
$str .= self::getImageHtml($action, $imgattr, $content, $params, $node_object);
|
|
}
|
|
return $str . '</div>';
|
|
}
|
|
|
|
/**
|
|
* Returns the overlay HTML.
|
|
* This needs to be inserted into the DOM only once, so a second call will return an empty string.
|
|
*
|
|
* @return string the PhotoSwipe overlay HTML
|
|
*/
|
|
static function getPhotoSwipeOverlay() {
|
|
global $lang;
|
|
|
|
$photoswipeoverlay = self::$photoswipeUiIsInitialized ? '' : '<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">' . //
|
|
'<div class="pswp__bg"></div>' . //
|
|
'<div class="pswp__scroll-wrap">' . //
|
|
'<div class="pswp__container">' . //
|
|
'<div class="pswp__item"></div>' . //
|
|
'<div class="pswp__item"></div>' . //
|
|
'<div class="pswp__item">' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'<div class="pswp__ui pswp__ui--hidden">' . //
|
|
'<div class="pswp__top-bar">' . //
|
|
'<div class="pswp__counter"></div>' . //
|
|
'<button class="pswp__button pswp__button--close" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_closebutton'] . '"></button>' . //
|
|
'<button class="pswp__button pswp__button--share" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_sharebutton'] . '"></button>' . //
|
|
'<button class="pswp__button pswp__button--fs" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_fullscreenbutton'] . '"></button>' . //
|
|
'<button class="pswp__button pswp__button--zoom" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_zoombutton'] . '"></button>' . //
|
|
'<div class="pswp__preloader">' . //
|
|
'<div class="pswp__preloader__icn">' . //
|
|
'<div class="pswp__preloader__cut">' . //
|
|
'<div class="pswp__preloader__donut"></div>' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">' . //
|
|
'<div class="pswp__share-tooltip"></div>' . //
|
|
'</div>' . //
|
|
'<button class="pswp__button pswp__button--arrow--left" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_prevbutton'] . '"></button>' . //
|
|
'<button class="pswp__button pswp__button--arrow--right" title="' . $lang ['plugin'] ['photoswipe'] ['tooltip_nextbutton'] . '"></button>' . //
|
|
'<div class="pswp__caption">' . //
|
|
'<div class="pswp__caption__center"></div>' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'</div>' . //
|
|
'</div>';
|
|
self::$photoswipeUiIsInitialized = true;
|
|
return $photoswipeoverlay;
|
|
}
|
|
|
|
/**
|
|
* Header hook for loading the PhotoSwipe scripts.
|
|
* Echoes the <script> tags.
|
|
*/
|
|
static function echoScriptTags() {
|
|
$pdir = plugin_geturl('photoswipe');
|
|
echo '<!-- PhotoSwipe -->
|
|
';
|
|
if (!function_exists('plugin_jquery_head')) {
|
|
echo '<script src="' . $pdir . 'res/jquery-2.2.2/jquery-2.2.2.min.js"></script>
|
|
';
|
|
}
|
|
echo '
|
|
<script src="' . $pdir . 'res/photoswipe-4.1.3/photoswipe-ui-default.min.js"></script>
|
|
<script src="' . $pdir . 'res/photoswipe-4.1.3/photoswipe.min.js"></script>
|
|
<script>';
|
|
include_once (dirname(__FILE__) . '/res/photoswipe.js.php');
|
|
echo '
|
|
</script>
|
|
<link rel="stylesheet" property="stylesheet" href="' . $pdir . 'res/photoswipe-4.1.3/default-skin/default-skin.css">
|
|
<link media="screen" href="' . $pdir . 'res/photoswipe-4.1.3/photoswipe.css" type="text/css" rel="stylesheet">
|
|
<!-- /PhotoSwipe -->';
|
|
}
|
|
|
|
/**
|
|
* Initializes the BBCode tags of the plugin.
|
|
*/
|
|
public static function initializePluginTags() {
|
|
// At first: check if BBCode plugin is active
|
|
if (!function_exists('plugin_bbcode_init')) {
|
|
// if not, there's no use in adding any bbcode tags :)
|
|
return;
|
|
}
|
|
|
|
// get the global bbcode object
|
|
$bbcode = plugin_bbcode_init();
|
|
|
|
// gallery tags
|
|
$supportedGalleryTags = array(
|
|
'gallery', // default tag
|
|
'photoswipegallery' // legacy tag - maintaining compatibility with plugin versions <= 1.1
|
|
);
|
|
foreach ($supportedGalleryTags as $tag) {
|
|
// add gallery tag
|
|
$bbcode->addCode($tag, // tag name: this will go between square brackets
|
|
'callback_replace_single', // type of action: we'll use a callback function
|
|
'PhotoSwipeFunctions::getGalleryHtml', // name of the callback function
|
|
array(
|
|
'usecontent_param' => array(
|
|
'default'
|
|
)
|
|
), // supported parameters: "default" is [acronym=valore]
|
|
'inline', // type of the tag, inline or block, etc
|
|
array(
|
|
'listitem',
|
|
'block',
|
|
'inline',
|
|
'link'
|
|
), // type of elements in which you can use this tag
|
|
array()); // type of elements where this tag CAN'T go (in this case, none, so it can go everywhere)
|
|
$bbcode->setCodeFlag($tag, 'closetag', BBCODE_CLOSETAG_FORBIDDEN); // a closing tag is forbidden (no [/tag])
|
|
}
|
|
|
|
// single image tags
|
|
$supportedImageTags = array(
|
|
'img', // default tag
|
|
'photoswipeimage' // legacy tag - maintaining compatibility with plugin versions <= 1.1
|
|
);
|
|
foreach ($supportedImageTags as $tag) {
|
|
// at first: remove tag to make sure it will be overridden
|
|
$bbcode->removeCode($tag);
|
|
// add image tag
|
|
$bbcode->addCode($tag, // tag name: this will go between square brackets
|
|
'callback_replace_single', // type of action: we'll use a callback function
|
|
'PhotoSwipeFunctions::getImageHtml', // name of the callback function
|
|
array(
|
|
'usecontent_param' => array(
|
|
'default'
|
|
)
|
|
), // supported parameters: "default" is [acronym=valore]
|
|
'inline', // type of the tag, inline or block, etc
|
|
array(
|
|
'listitem',
|
|
'block',
|
|
'inline',
|
|
'link'
|
|
), // type of elements in which you can use this tag
|
|
array()); // type of elements where this tag CAN'T go (in this case, none, so it can go everywhere)
|
|
$bbcode->setCodeFlag($tag, 'closetag', BBCODE_CLOSETAG_FORBIDDEN); // a closing tag is forbidden (no [/tag])
|
|
}
|
|
}
|
|
|
|
}
|