summaryrefslogtreecommitdiffstats
path: root/articleenhancer/globalarticleenhancer.php
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-21 16:45:36 +0200
commit42d69a95f3276a2d6089ca68f635c4e2f6aa7a23 (patch)
tree6a17fd7998f291e6dec1d996c1e7c724b92b8e58 /articleenhancer/globalarticleenhancer.php
parent0e6598b0734fb927109f745d9c0f3a8605a30ca5 (diff)
convert tabs indention to indention with 4 spaces because of mixing of both variants in code and better readability on github and websites because you cant set the indention width there and 8 spaces will be used for a tab
Diffstat (limited to 'articleenhancer/globalarticleenhancer.php')
-rw-r--r--articleenhancer/globalarticleenhancer.php62
1 files changed, 31 insertions, 31 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php
index 117c0981c..b556a285a 100644
--- a/articleenhancer/globalarticleenhancer.php
+++ b/articleenhancer/globalarticleenhancer.php
@@ -21,47 +21,47 @@ use \OCA\News\Db\Item;
class GlobalArticleEnhancer implements ArticleEnhancer {
- /**
- * This method is run after all enhancers and for every item
- */
- public function enhance(Item $item) {
+ /**
+ * This method is run after all enhancers and for every item
+ */
+ public function enhance(Item $item) {
- $dom = new \DOMDocument();
+ $dom = new \DOMDocument();
- // wrap it inside a div if there is none to prevent invalid wrapping
- // inside <p> tags
- $body = '<div>' . $item->getBody() . '</div>';
+ // wrap it inside a div if there is none to prevent invalid wrapping
+ // inside <p> tags
+ $body = '<div>' . $item->getBody() . '</div>';
- Security::scan($body, $dom, function ($xml, $dom) {
- return @$dom->loadHTML($xml, LIBXML_HTML_NOIMPLIED
- | LIBXML_HTML_NODEFDTD | LIBXML_NONET);
- });
+ Security::scan($body, $dom, function ($xml, $dom) {
+ return @$dom->loadHTML($xml, LIBXML_HTML_NOIMPLIED
+ | LIBXML_HTML_NODEFDTD | LIBXML_NONET);
+ });
- $xpath = new \DOMXpath($dom);
+ $xpath = new \DOMXpath($dom);
- // remove youtube autoplay
- // NOTE: PHP supports only XPath 1.0 so no matches() function :(
- $youtubeIframes = "//iframe[contains(@src, 'youtube.com')]";
+ // remove youtube autoplay
+ // NOTE: PHP supports only XPath 1.0 so no matches() function :(
+ $youtubeIframes = "//iframe[contains(@src, 'youtube.com')]";
- $elements = $xpath->query($youtubeIframes);
- foreach ($elements as $element) {
+ $elements = $xpath->query($youtubeIframes);
+ foreach ($elements as $element) {
- // src needs to be matched against regex to prevent false positives
- // and because theres no XPath matches function available
- $src = $element->getAttribute('src');
- $regex = '%^(http://|https://|//)(www\.)?youtube.com/.*\?.*autoplay=1.*%i';
+ // src needs to be matched against regex to prevent false positives
+ // and because theres no XPath matches function available
+ $src = $element->getAttribute('src');
+ $regex = '%^(http://|https://|//)(www\.)?youtube.com/.*\?.*autoplay=1.*%i';
- if (preg_match($regex, $src)) {
- $replaced = str_replace('autoplay=1', 'autoplay=0', $src);
- $element->setAttribute('src', $replaced);
- }
- }
+ if (preg_match($regex, $src)) {
+ $replaced = str_replace('autoplay=1', 'autoplay=0', $src);
+ $element->setAttribute('src', $replaced);
+ }
+ }
- // save all changes back to the item
- $item->setBody(trim($dom->saveHTML()));
+ // save all changes back to the item
+ $item->setBody(trim($dom->saveHTML()));
- return $item;
- }
+ return $item;
+ }
} \ No newline at end of file