3
3
use dokuwiki \Extension \ActionPlugin ;
4
4
use dokuwiki \Extension \EventHandler ;
5
5
use dokuwiki \Extension \Event ;
6
+ use dokuwiki \plugin \gallery \classes \Options ;
6
7
use dokuwiki \plugin \gallery \GalleryNode ;
7
8
use dokuwiki \plugin \prosemirror \parser \RootNode ;
8
9
use dokuwiki \plugin \prosemirror \schema \Node ;
@@ -42,18 +43,33 @@ public function writeDefaultsToJSINFO(Event $event, $param)
42
43
{
43
44
global $ JSINFO ;
44
45
45
- /** @var syntax_plugin_gallery $syntax */
46
- $ syntax = plugin_load ('syntax ' , 'gallery ' );
47
- $ defaults = $ syntax ->getDataFromParams ($ syntax ->getConf ('options ' ));
48
- $ attributes = $ this ->cleanAttributes ($ defaults );
46
+ $ options = new Options ();
47
+ $ defaults = [
48
+ 'thumbnailsize ' => $ options ->thumbnailWidth . 'x ' . $ options ->thumbnailHeight ,
49
+ 'imagesize ' => $ options ->lightboxWidth . 'X ' . $ options ->lightboxHeight ,
50
+ 'cache ' => $ options ->cache ,
51
+ 'filter ' => $ options ->filter ,
52
+ 'showname ' => $ options ->showname ,
53
+ 'showtitle ' => $ options ->showtitle ,
54
+ 'crop ' => $ options ->crop ,
55
+ 'direct ' => $ options ->direct ,
56
+ 'reverse ' => $ options ->reverse ,
57
+ 'recursive ' => $ options ->recursive ,
58
+ 'align ' => $ options ->align ,
59
+ 'cols ' => $ options ->columns ,
60
+ 'limit ' => $ options ->limit ,
61
+ 'offset ' => $ options ->offset ,
62
+ 'paginate ' => $ options ->paginate ,
63
+ 'sort ' => $ options ->sort ,
64
+ ];
49
65
50
66
if (!isset ($ JSINFO ['plugins ' ])) {
51
67
$ JSINFO ['plugins ' ] = [];
52
68
}
53
69
$ JSINFO ['plugins ' ]['gallery ' ] = [
54
70
'defaults ' => array_map (function ($ default ) {
55
71
return ['default ' => $ default ,];
56
- }, $ attributes ),
72
+ }, $ defaults ),
57
73
];
58
74
$ JSINFO ['plugins ' ]['gallery ' ]['defaults ' ]['namespace ' ] = ['default ' => '' ];
59
75
}
@@ -82,7 +98,6 @@ public function renderFromInstructions(Event $event, $param)
82
98
// FIXME we may have to parse the namespace from the original syntax ?
83
99
$ data = $ event ->data ['data ' ];
84
100
$ ns = $ data ['ns ' ];
85
- $ data = $ this ->cleanAttributes ($ data );
86
101
87
102
if (cleanID ($ ns ) === $ ns ) {
88
103
$ ns = ': ' . $ ns ;
@@ -94,37 +109,6 @@ public function renderFromInstructions(Event $event, $param)
94
109
$ event ->data ['renderer ' ]->nodestack ->add ($ node );
95
110
}
96
111
97
- /**
98
- * Slightly rewrite the attributes to the format expected by our schema
99
- *
100
- * @param $data
101
- *
102
- * @return mixed
103
- */
104
- public function cleanAttributes ($ data )
105
- {
106
- $ data ['thumbnailsize ' ] = $ data ['tw ' ] . 'x ' . $ data ['th ' ];
107
- $ data ['imagesize ' ] = $ data ['iw ' ] . 'X ' . $ data ['ih ' ];
108
- if ($ data ['random ' ]) {
109
- $ data ['sort ' ] = 'random ' ;
110
- } else {
111
- $ data ['sort ' ] .= 'sort ' ;
112
- }
113
-
114
- if ($ data ['align ' ] === 1 ) {
115
- $ data ['align ' ] = 'right ' ;
116
- } elseif ($ data ['align ' ] === 2 ) {
117
- $ data ['align ' ] = 'left ' ;
118
- } else {
119
- $ data ['align ' ] = 'center ' ;
120
- }
121
-
122
- unset($ data ['tw ' ], $ data ['th ' ], $ data ['iw ' ], $ data ['ih ' ], $ data ['random ' ]);
123
- unset($ data ['ns ' ], $ data ['galid ' ]);
124
-
125
- return $ data ;
126
- }
127
-
128
112
/**
129
113
* Render our syntax instructions for prosemirror
130
114
*
0 commit comments