1<?php
2
3use dokuwiki\plugin\gallery\classes\Options;
4
5/**
6 * DokuWiki Plugin gallery (Syntax Component)
7 *
8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
9 * @author  Andreas Gohr <andi@splitbrain.org>
10 */
11class syntax_plugin_gallery_list extends syntax_plugin_gallery_main
12{
13    /** @inheritDoc */
14    public function connectTo($mode)
15    {
16        $this->Lexer->addSpecialPattern('<gallery.*?>.+?</gallery>', $mode, 'plugin_gallery_list');
17    }
18
19    /** @inheritDoc */
20    public function handle($match, $state, $pos, Doku_Handler $handler)
21    {
22        $match = substr($match, 8, -10); //strip markup from start and end
23        [$params, $list] = sexplode('>', $match, 2);
24
25        $options = new Options();
26        $options->parseParameters($params);
27
28        $list = explode("\n", $list);
29        $list = array_map('trim', $list);
30        $list = array_filter($list);
31
32        return [$list, $options];
33    }
34}
35