mirror of
https://github.com/splitbrain/dokuwiki-plugin-gallery.git
synced 2025-07-21 11:32:13 +00:00
🤖 Automatic code style fixes
This commit is contained in:
@ -6,7 +6,6 @@ use dokuwiki\plugin\prosemirror\parser\Node;
|
||||
|
||||
class GalleryNode extends Node
|
||||
{
|
||||
|
||||
protected $parent;
|
||||
protected $data;
|
||||
|
||||
@ -77,7 +76,7 @@ class GalleryNode extends Node
|
||||
$alignLeft = $attrs['align'] === 'left' ? ' ' : '';
|
||||
$alignRight = $attrs['align'] === 'right' ? ' ' : '';
|
||||
$result = '{{gallery>' . $alignRight . $attrs['namespace'];
|
||||
if (!empty($query)) {
|
||||
if ($query !== []) {
|
||||
$result .= '?' . implode('&', $query);
|
||||
}
|
||||
$result .= $alignLeft . '}}';
|
||||
|
@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
use dokuwiki\Extension\ActionPlugin;
|
||||
use dokuwiki\Extension\EventHandler;
|
||||
use dokuwiki\Extension\Event;
|
||||
use dokuwiki\plugin\gallery\GalleryNode;
|
||||
use dokuwiki\plugin\prosemirror\parser\RootNode;
|
||||
use dokuwiki\plugin\prosemirror\schema\Node;
|
||||
|
||||
class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
class action_plugin_gallery_prosemirror extends ActionPlugin
|
||||
{
|
||||
/**
|
||||
* Registers a callback function for a given event
|
||||
@ -13,7 +16,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(Doku_Event_Handler $controller)
|
||||
public function register(EventHandler $controller)
|
||||
{
|
||||
// check if prosemirror is installed
|
||||
if (!class_exists('\dokuwiki\plugin\prosemirror\schema\Node')) return;
|
||||
@ -35,7 +38,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function writeDefaultsToJSINFO(Doku_Event $event, $param)
|
||||
public function writeDefaultsToJSINFO(Event $event, $param)
|
||||
{
|
||||
global $JSINFO;
|
||||
|
||||
@ -67,7 +70,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function renderFromInstructions(Doku_Event $event, $param)
|
||||
public function renderFromInstructions(Event $event, $param)
|
||||
{
|
||||
if ($event->data['name'] !== 'gallery') {
|
||||
return;
|
||||
@ -110,7 +113,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
|
||||
if ($data['align'] === 1) {
|
||||
$data['align'] = 'right';
|
||||
} else if ($data['align'] === 2) {
|
||||
} elseif ($data['align'] === 2) {
|
||||
$data['align'] = 'left';
|
||||
} else {
|
||||
$data['align'] = 'center';
|
||||
@ -133,7 +136,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function parseToSyntax(Doku_Event $event, $param)
|
||||
public function parseToSyntax(Event $event, $param)
|
||||
{
|
||||
if ($event->data['node']['type'] !== 'dwplugin_gallery') {
|
||||
return;
|
||||
@ -155,7 +158,7 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function renderAttributesToHTML(Doku_Event $event, $param)
|
||||
public function renderAttributesToHTML(Event $event, $param)
|
||||
{
|
||||
if ($event->data !== 'plugin_gallery_prosemirror') {
|
||||
return;
|
||||
@ -170,4 +173,3 @@ class action_plugin_gallery_prosemirror extends DokuWiki_Action_Plugin
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace dokuwiki\plugin\gallery\classes;
|
||||
|
||||
|
||||
/**
|
||||
* Formats the gallery
|
||||
*
|
||||
@ -10,8 +9,8 @@ namespace dokuwiki\plugin\gallery\classes;
|
||||
* good, but will work with any renderer. Specialized formatters can be created for each renderer to make
|
||||
* use of their special features.
|
||||
*/
|
||||
class BasicFormatter {
|
||||
|
||||
class BasicFormatter
|
||||
{
|
||||
protected Options $options;
|
||||
protected \Doku_Renderer $renderer;
|
||||
|
||||
@ -47,8 +46,9 @@ class BasicFormatter {
|
||||
* @param Image $image
|
||||
* @return void
|
||||
*/
|
||||
protected function renderImage(Image $image) {
|
||||
list($w, $h) = $this->getThumbnailSize($image);
|
||||
protected function renderImage(Image $image)
|
||||
{
|
||||
[$w, $h] = $this->getThumbnailSize($image);
|
||||
$link = $image->getDetaillink() ?: $image->getSrc();
|
||||
|
||||
$imgdata = [
|
||||
@ -60,7 +60,7 @@ class BasicFormatter {
|
||||
'cache' => ''
|
||||
];
|
||||
|
||||
if($image->isExternal()) {
|
||||
if ($image->isExternal()) {
|
||||
$this->renderer->externallink($link, $imgdata);
|
||||
} else {
|
||||
$this->renderer->internalmedia(":$link", $imgdata); // prefix with : to ensure absolute src
|
||||
@ -80,7 +80,7 @@ class BasicFormatter {
|
||||
$crop = true;
|
||||
}
|
||||
if (!$crop) {
|
||||
list($thumbWidth, $thumbHeight) = $this->fitBoundingBox(
|
||||
[$thumbWidth, $thumbHeight] = $this->fitBoundingBox(
|
||||
$image->getWidth(),
|
||||
$image->getHeight(),
|
||||
$this->options->thumbnailWidth,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace dokuwiki\plugin\gallery\classes;
|
||||
|
||||
use SimplePie\Enclosure;
|
||||
use FeedParser;
|
||||
|
||||
class FeedGallery extends AbstractGallery
|
||||
@ -27,15 +28,17 @@ class FeedGallery extends AbstractGallery
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function parseFeed($url) {
|
||||
protected function parseFeed($url)
|
||||
{
|
||||
$feed = new FeedParser();
|
||||
$feed->set_feed_url($url);
|
||||
|
||||
$ok = $feed->init();
|
||||
if (!$ok) throw new \Exception($feed->error());
|
||||
|
||||
foreach ($feed->get_items() as $item) {
|
||||
$enclosure = $item->get_enclosure();
|
||||
if (!$enclosure) continue;
|
||||
if (!$enclosure instanceof Enclosure) continue;
|
||||
|
||||
// skip non-image enclosures
|
||||
if ($enclosure->get_type() && substr($enclosure->get_type(), 0, 5) != 'image') {
|
||||
@ -87,7 +90,7 @@ class FeedGallery extends AbstractGallery
|
||||
protected function initBaseUrl($url)
|
||||
{
|
||||
$main = parse_url($url);
|
||||
$this->feedHost = $main['scheme'] . '://' . $main['host'] . (!empty($main['port']) ? ':' . $main['port'] : '');
|
||||
$this->feedHost = $main['scheme'] . '://' . $main['host'] . (empty($main['port']) ? '' : ':' . $main['port']);
|
||||
$this->feedPath = dirname($main['path']) . '/';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use dokuwiki\Utf8\PhpString;
|
||||
|
||||
class Image
|
||||
{
|
||||
const IMG_REGEX = '/\.(jpe?g|gif|png|svg|webp)$/i';
|
||||
public const IMG_REGEX = '/\.(jpe?g|gif|png|svg|webp)$/i';
|
||||
|
||||
protected $isExternal = false;
|
||||
protected $src;
|
||||
|
@ -4,7 +4,6 @@ namespace dokuwiki\plugin\gallery\classes;
|
||||
|
||||
class NamespaceGallery extends AbstractGallery
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public function __construct($ns, $options)
|
||||
{
|
||||
|
@ -4,17 +4,16 @@ namespace dokuwiki\plugin\gallery\classes;
|
||||
|
||||
class Options
|
||||
{
|
||||
public const SORT_FILE = 'file';
|
||||
public const SORT_CTIME = 'date';
|
||||
public const SORT_MTIME = 'mod';
|
||||
public const SORT_TITLE = 'title';
|
||||
public const SORT_RANDOM = 'random';
|
||||
|
||||
const SORT_FILE = 'file';
|
||||
const SORT_CTIME = 'date';
|
||||
const SORT_MTIME = 'mod';
|
||||
const SORT_TITLE = 'title';
|
||||
const SORT_RANDOM = 'random';
|
||||
|
||||
const ALIGN_FULL = 0;
|
||||
const ALIGN_LEFT = 1;
|
||||
const ALIGN_RIGHT = 2;
|
||||
const ALIGN_CENTER = 3;
|
||||
public const ALIGN_FULL = 0;
|
||||
public const ALIGN_LEFT = 1;
|
||||
public const ALIGN_RIGHT = 2;
|
||||
public const ALIGN_CENTER = 3;
|
||||
|
||||
// defaults
|
||||
public string $galleryID = '';
|
||||
@ -116,5 +115,4 @@ class Options
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,8 @@
|
||||
|
||||
namespace dokuwiki\plugin\gallery\classes;
|
||||
|
||||
|
||||
class XHTMLFormatter extends BasicFormatter
|
||||
{
|
||||
|
||||
// region Main Render Functions
|
||||
|
||||
/** @inheritdoc */
|
||||
@ -105,7 +103,7 @@ class XHTMLFormatter extends BasicFormatter
|
||||
global $ID;
|
||||
|
||||
// thumbnail image properties
|
||||
list($w, $h) = $this->getThumbnailSize($image);
|
||||
[$w, $h] = $this->getThumbnailSize($image);
|
||||
$w *= 2; // retina
|
||||
$h *= 2;
|
||||
$img = [];
|
||||
@ -122,7 +120,7 @@ class XHTMLFormatter extends BasicFormatter
|
||||
|
||||
if ($this->options->lightbox) {
|
||||
// double escape for lightbox:
|
||||
$a['data-caption'] = join(' – ', array_filter([
|
||||
$a['data-caption'] = implode(' – ', array_filter([
|
||||
'<b>' . hsc($image->getTitle()) . '</b>',
|
||||
hsc($image->getDescription())
|
||||
]));
|
||||
@ -210,7 +208,7 @@ class XHTMLFormatter extends BasicFormatter
|
||||
}
|
||||
|
||||
// fit into bounding box
|
||||
list($width, $height) = $this->fitBoundingBox(
|
||||
[$width, $height] = $this->fitBoundingBox(
|
||||
$image->getWidth(),
|
||||
$image->getHeight(),
|
||||
$this->options->lightboxWidth,
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Options for the gallery plugin
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Options for the gallery plugin
|
||||
*
|
||||
@ -34,4 +35,3 @@ $meta['options'] = array('multicheckbox', '_choices' => array(
|
||||
'showname',
|
||||
'showtitle',
|
||||
));
|
||||
|
||||
|
@ -10,7 +10,6 @@ use dokuwiki\plugin\gallery\classes\Options;
|
||||
*/
|
||||
class syntax_plugin_gallery_list extends syntax_plugin_gallery_main
|
||||
{
|
||||
|
||||
/** @inheritDoc */
|
||||
public function connectTo($mode)
|
||||
{
|
||||
@ -33,4 +32,3 @@ class syntax_plugin_gallery_list extends syntax_plugin_gallery_main
|
||||
return [$list, $options];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use dokuwiki\Extension\SyntaxPlugin;
|
||||
use dokuwiki\File\PageResolver;
|
||||
use dokuwiki\plugin\gallery\classes\BasicFormatter;
|
||||
use dokuwiki\plugin\gallery\classes\FeedGallery;
|
||||
@ -16,9 +17,8 @@ use dokuwiki\plugin\gallery\classes\XHTMLFormatter;
|
||||
* @author Joe Lapp <joe.lapp@pobox.com>
|
||||
* @author Dave Doyle <davedoyle.canadalawbook.ca>
|
||||
*/
|
||||
class syntax_plugin_gallery_main extends DokuWiki_Syntax_Plugin
|
||||
class syntax_plugin_gallery_main extends SyntaxPlugin
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public function getType()
|
||||
{
|
||||
@ -59,7 +59,7 @@ class syntax_plugin_gallery_main extends DokuWiki_Syntax_Plugin
|
||||
if (substr($match, -1, 1) == ' ') $options->align += Options::ALIGN_LEFT;
|
||||
|
||||
// extract src and params
|
||||
list($src, $params) = sexplode('?', $match, 2);
|
||||
[$src, $params] = sexplode('?', $match, 2);
|
||||
$src = trim($src);
|
||||
|
||||
// resolve relative namespace
|
||||
@ -82,7 +82,6 @@ class syntax_plugin_gallery_main extends DokuWiki_Syntax_Plugin
|
||||
[$src, $options] = $data;
|
||||
|
||||
try {
|
||||
|
||||
if (is_array($src)) {
|
||||
$gallery = new ListGallery($src, $options);
|
||||
} elseif (preg_match('/^https?:\/\//i', $src)) {
|
||||
@ -92,13 +91,10 @@ class syntax_plugin_gallery_main extends DokuWiki_Syntax_Plugin
|
||||
}
|
||||
|
||||
$R->info['cache'] = $options->cache;
|
||||
switch ($mode) {
|
||||
case 'xhtml':
|
||||
$formatter = new XHTMLFormatter($R, $options);
|
||||
break;
|
||||
// FIXME additional specialized Formatters could be added here (PDF, ODT)
|
||||
default:
|
||||
$formatter = new BasicFormatter($R, $options);
|
||||
if ($mode == 'xhtml') {
|
||||
$formatter = new XHTMLFormatter($R, $options);
|
||||
} else {
|
||||
$formatter = new BasicFormatter($R, $options);
|
||||
}
|
||||
$formatter->render($gallery);
|
||||
} catch (Exception $e) {
|
||||
|
Reference in New Issue
Block a user