Total Complexity | 28 |
Total Lines | 174 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class ImageNode extends Node implements InlineNodeInterface |
||
6 | { |
||
7 | |||
8 | /** @var Node */ |
||
9 | protected $parent; |
||
10 | |||
11 | protected $attrs = []; |
||
12 | |||
13 | protected $textNode = null; |
||
14 | |||
15 | public function __construct($data, $parent, $previousNode = false) |
||
16 | { |
||
17 | $this->parent = &$parent; |
||
18 | $this->attrs = $data['attrs']; |
||
19 | |||
20 | // every inline node needs a TextNode to track marks |
||
21 | $this->textNode = new TextNode(['marks' => $data['marks']], $parent, $previousNode); |
||
22 | } |
||
23 | |||
24 | public function toSyntax() |
||
62 | } |
||
63 | |||
64 | public static function render( |
||
96 | } |
||
97 | |||
98 | public static function addAttributes( |
||
99 | \dokuwiki\plugin\prosemirror\schema\Node $node, |
||
100 | $src, |
||
101 | $title = null, |
||
102 | $align = null, |
||
103 | $width = null, |
||
104 | $height = null, |
||
105 | $cache = null, |
||
106 | $linking = null, |
||
107 | $prefix = '' |
||
108 | ) { |
||
109 | $node->attr($prefix . 'src', ml($src)); |
||
1 ignored issue
–
show
|
|||
110 | $node->attr($prefix . 'title', $title); |
||
111 | |||
112 | $class = 'media'; |
||
113 | if ($align === 'right') { |
||
114 | $class = 'mediaright'; |
||
115 | } elseif ($align === 'left') { |
||
116 | $class = 'medialeft'; |
||
117 | } elseif ($align === 'center') { |
||
118 | $class = 'mediacenter'; |
||
119 | } |
||
120 | |||
121 | if ($cache !== null && $cache === 'cache') { |
||
122 | $cache = null; |
||
123 | } |
||
124 | |||
125 | $node->attr($prefix . 'class', $class); |
||
126 | $node->attr($prefix . 'align', $align); |
||
127 | $node->attr($prefix . 'width', $width); |
||
128 | $node->attr($prefix . 'height', $height); |
||
129 | $node->attr($prefix . 'id', $src); |
||
130 | $node->attr($prefix . 'cache', $cache); |
||
131 | $node->attr($prefix . 'linking', $linking); |
||
132 | } |
||
133 | |||
134 | public static function resolveMedia( |
||
135 | $src, |
||
136 | $title = null, |
||
137 | $align = null, |
||
138 | $width = null, |
||
139 | $height = null, |
||
140 | $cache = null, |
||
141 | $linking = null |
||
142 | ) { |
||
143 | $xhtml_renderer = p_get_renderer('xhtml'); |
||
1 ignored issue
–
show
|
|||
144 | if (media_isexternal($src) || link_isinterwiki($src)) { |
||
2 ignored issues
–
show
|
|||
145 | $xhtml_renderer->externalmedia( |
||
146 | $src, |
||
147 | $title ?: $src, |
||
148 | $align, |
||
149 | $width, |
||
150 | $height, |
||
151 | $cache, |
||
152 | $linking |
||
153 | ); |
||
154 | } else { |
||
155 | $xhtml_renderer->internalmedia( |
||
156 | $src, |
||
157 | $title ?: $src, |
||
158 | $align, |
||
159 | $width, |
||
160 | $height, |
||
161 | $cache, |
||
162 | $linking |
||
163 | ); |
||
164 | } |
||
165 | return $xhtml_renderer->doc; |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * @param string $markType |
||
170 | */ |
||
171 | public function increaseMark($markType) |
||
172 | { |
||
173 | return $this->textNode->increaseMark($markType); |
||
174 | } |
||
175 | |||
176 | public function getStartingNodeMarkScore($markType) |
||
179 | } |
||
180 | } |
||
181 |