|
@@ -136,10 +136,10 @@ discard block |
|
|
block discarded – undo |
|
136
|
136
|
$domElementA = $this->buildElement($document, $options[self::MAIN_TAG_KEY][0]); |
|
137
|
137
|
|
|
138
|
138
|
//Merge font size and font family to add inside the second wrapping DOMElement. |
|
139
|
|
- if(!array_key_exists(self::MAIN_TAG_MERGE_STYLE, $options) || !is_bool($options[self::MAIN_TAG_MERGE_STYLE])) { |
|
|
139
|
+ if (!array_key_exists(self::MAIN_TAG_MERGE_STYLE, $options) || !is_bool($options[self::MAIN_TAG_MERGE_STYLE])) { |
|
140
|
140
|
$options[self::MAIN_TAG_MERGE_STYLE] = true; |
|
141
|
141
|
} |
|
142
|
|
- if($options[self::MAIN_TAG_MERGE_STYLE]) { |
|
|
142
|
+ if ($options[self::MAIN_TAG_MERGE_STYLE]) { |
|
143
|
143
|
$options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY] = array_merge( |
|
144
|
144
|
$options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY], |
|
145
|
145
|
[ |
|
@@ -149,24 +149,23 @@ discard block |
|
|
block discarded – undo |
|
149
|
149
|
] |
|
150
|
150
|
); |
|
151
|
151
|
} |
|
152
|
|
- $options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY] = array_merge($options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY], ['id' => $node->getId(),]); |
|
|
152
|
+ $options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY] = array_merge($options[self::MAIN_TAG_KEY][1][self::ATTRIBUTES_KEY], ['id' => $node->getId(), ]); |
|
153
|
153
|
//Create the second wrapping DOMElement whom will be append to the first one |
|
154
|
154
|
$domElementB = $this->buildElement($document, $options[self::MAIN_TAG_KEY][1]); |
|
155
|
155
|
|
|
156
|
156
|
//Set the icon in an img tag whom will be wrapped in the second DOMElement. |
|
157
|
|
- if(!empty($node->getIcon()) && $options[self::MAIN_ICON_KEY][self::DISPLAY_ICON_KEY]) { |
|
|
157
|
+ if (!empty($node->getIcon()) && $options[self::MAIN_ICON_KEY][self::DISPLAY_ICON_KEY]) { |
|
158
|
158
|
$icon = $node->getIcon(); |
|
159
|
159
|
$domElementImg = $document->createElement('img'); |
|
160
|
160
|
|
|
161
|
161
|
$iconUri = $icon->getShortUri(); |
|
162
|
|
- if(array_key_exists(self::PATH_ICON_KEY, $options[self::MAIN_ICON_KEY])) { |
|
163
|
|
- if(!is_callable($callback = $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::CALLBACK_PATH_ICON_KEY])) { |
|
|
162
|
+ if (array_key_exists(self::PATH_ICON_KEY, $options[self::MAIN_ICON_KEY])) { |
|
|
163
|
+ if (!is_callable($callback = $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::CALLBACK_PATH_ICON_KEY])) { |
|
164
|
164
|
throw new InvalidArgumentException('The argument with the key "'.self::CALLBACK_PATH_ICON_KEY.'" (self::CALLBACK_PATH_ICON_KEY) must be a valid callback.'); |
|
165
|
165
|
} |
|
166
|
166
|
|
|
167
|
167
|
$callBackoptions = array_key_exists(self::OPTIONS_PATH_ICON_KEY, $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY]) ? |
|
168
|
|
- $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::OPTIONS_PATH_ICON_KEY] : |
|
169
|
|
- null; |
|
|
168
|
+ $options[self::MAIN_ICON_KEY][self::PATH_ICON_KEY][self::OPTIONS_PATH_ICON_KEY] : null; |
|
170
|
169
|
|
|
171
|
170
|
$iconUri = $callback($icon->getFullName(), $callBackoptions); |
|
172
|
171
|
} |
|
@@ -180,16 +179,16 @@ discard block |
|
|
block discarded – undo |
|
180
|
179
|
$text = $document->createTextNode($node->getText()); |
|
181
|
180
|
|
|
182
|
181
|
//Bold an italic in old HTML way in order not to spread it to all children. |
|
183
|
|
- if(!array_key_exists(self::MAIN_TAG_MERGE_DECORATION, $options) || !is_bool($options[self::MAIN_TAG_MERGE_DECORATION])) { |
|
|
182
|
+ if (!array_key_exists(self::MAIN_TAG_MERGE_DECORATION, $options) || !is_bool($options[self::MAIN_TAG_MERGE_DECORATION])) { |
|
184
|
183
|
$options[self::MAIN_TAG_MERGE_DECORATION] = true; |
|
185
|
184
|
} |
|
186
|
|
- if($options[self::MAIN_TAG_MERGE_DECORATION]) { |
|
187
|
|
- if($node->isBold()) { |
|
|
185
|
+ if ($options[self::MAIN_TAG_MERGE_DECORATION]) { |
|
|
186
|
+ if ($node->isBold()) { |
|
188
|
187
|
$bTag = $document->createElement('b'); |
|
189
|
188
|
$bTag->appendChild($text); |
|
190
|
189
|
$text = $bTag; |
|
191
|
190
|
} |
|
192
|
|
- if($node->isItalic()) { |
|
|
191
|
+ if ($node->isItalic()) { |
|
193
|
192
|
$iTag = $document->createElement('i'); |
|
194
|
193
|
$iTag->appendChild($text); |
|
195
|
194
|
$text = $iTag; |
|
@@ -197,7 +196,7 @@ discard block |
|
|
block discarded – undo |
|
197
|
196
|
} |
|
198
|
197
|
|
|
199
|
198
|
//Append text node (real one or the one already wrapped inside <b> and/or <i> tags) |
|
200
|
|
- if(isset($options[self::MAIN_TAG_KEY][2])) { |
|
|
199
|
+ if (isset($options[self::MAIN_TAG_KEY][2])) { |
|
201
|
200
|
$domElementC = $this->buildElement($document, $options[self::MAIN_TAG_KEY][2]); |
|
202
|
201
|
$domElementC->appendChild($text); |
|
203
|
202
|
$domElementB->appendChild($domElementC); |
|
@@ -208,7 +207,7 @@ discard block |
|
|
block discarded – undo |
|
208
|
207
|
|
|
209
|
208
|
$domElementA->appendChild($domElementB); |
|
210
|
209
|
|
|
211
|
|
- foreach($node->getChildren() as $child) { |
|
|
210
|
+ foreach ($node->getChildren() as $child) { |
|
212
|
211
|
$domElementB->appendChild($this->buildHTMLTreeFromNode($document, $child, $options)); |
|
213
|
212
|
} |
|
214
|
213
|
|
|
@@ -225,7 +224,7 @@ discard block |
|
|
block discarded – undo |
|
225
|
224
|
*/ |
|
226
|
225
|
private function buildElement(DOMDocument $document, array $description) { |
|
227
|
226
|
$domElement = $document->createElement($description[self::TAG_KEY]); |
|
228
|
|
- foreach($description[self::ATTRIBUTES_KEY] as $name => $attribute) { |
|
|
227
|
+ foreach ($description[self::ATTRIBUTES_KEY] as $name => $attribute) { |
|
229
|
228
|
$domElement->setAttribute($name, $attribute); |
|
230
|
229
|
} |
|
231
|
230
|
|