diff --git a/lang/en/lang.php b/lang/en/lang.php index e4582a9..282733e 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -3,6 +3,7 @@ $lang['pages'] = 'Gallery Pages:'; $lang['js']['addgal'] = 'Add namespace as gallery'; $lang['nothingfound'] = 'No images found.'; +$lang['fail'] = 'Failed to load gallery'; $lang['js']['label_toolbar_button'] = 'Insert Gallery'; diff --git a/syntax/main.php b/syntax/main.php index 4a72d0c..bd4d1e5 100644 --- a/syntax/main.php +++ b/syntax/main.php @@ -4,9 +4,9 @@ use dokuwiki\File\PageResolver; use dokuwiki\plugin\gallery\classes\BasicFormatter; use dokuwiki\plugin\gallery\classes\FeedGallery; use dokuwiki\plugin\gallery\classes\ListGallery; -use dokuwiki\plugin\gallery\classes\XHTMLFormatter; use dokuwiki\plugin\gallery\classes\NamespaceGallery; use dokuwiki\plugin\gallery\classes\Options; +use dokuwiki\plugin\gallery\classes\XHTMLFormatter; /** * Embed an image gallery @@ -81,24 +81,30 @@ class syntax_plugin_gallery_main extends DokuWiki_Syntax_Plugin { [$src, $options] = $data; - if (is_array($src)) { - $gallery = new ListGallery($src, $options); - } elseif (preg_match('/^https?:\/\//i', $src)) { - $gallery = new FeedGallery($src, $options); - } else { - $gallery = new NamespaceGallery($src, $options); - } + try { - $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 (is_array($src)) { + $gallery = new ListGallery($src, $options); + } elseif (preg_match('/^https?:\/\//i', $src)) { + $gallery = new FeedGallery($src, $options); + } else { + $gallery = new NamespaceGallery($src, $options); + } + + $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); + } + $formatter->render($gallery); + } catch (Exception $e) { + msg(hsc($e->getMessage()), -1); + $R->cdata($this->getLang('fail')); } - $formatter->render($gallery); return true; } }