@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $this->attempts[] = ['articleContent' => $result, 'textLength' => $length]; |
| 195 | 195 | |
| 196 | 196 | // No luck after removing flags, just return the longest text we found during the different loops |
| 197 | - usort($this->attempts, function ($a, $b) { |
|
| 197 | + usort($this->attempts, function($a, $b) { |
|
| 198 | 198 | return $a['textLength'] < $b['textLength']; |
| 199 | 199 | }); |
| 200 | 200 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // Prepend the XML tag to avoid having issues with special characters. Should be harmless. |
| 276 | - $dom->loadHTML('<?xml encoding="UTF-8">' . $html); |
|
| 276 | + $dom->loadHTML('<?xml encoding="UTF-8">'.$html); |
|
| 277 | 277 | $dom->encoding = 'UTF-8'; |
| 278 | 278 | |
| 279 | 279 | $this->removeScripts($dom); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * I can assure you it works properly if you let the code run. |
| 492 | 492 | */ |
| 493 | 493 | if (preg_match('/ [\|\-\\\\\/>»] /i', $curTitle)) { |
| 494 | - $titleHadHierarchicalSeparators = (bool)preg_match('/ [\\\\\/>»] /', $curTitle); |
|
| 494 | + $titleHadHierarchicalSeparators = (bool) preg_match('/ [\\\\\/>»] /', $curTitle); |
|
| 495 | 495 | $curTitle = preg_replace('/(.*)[\|\-\\\\\/>»] .*/i', '$1', $originalTitle); |
| 496 | 496 | |
| 497 | 497 | $this->logger->info(sprintf('[Metadata] Found hierarchical separators in title, new title is: \'%s\'', $curTitle)); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | // could assume it's the full title. |
| 508 | 508 | $match = false; |
| 509 | 509 | for ($i = 1; $i <= 2; $i++) { |
| 510 | - foreach ($this->dom->getElementsByTagName('h' . $i) as $hTag) { |
|
| 510 | + foreach ($this->dom->getElementsByTagName('h'.$i) as $hTag) { |
|
| 511 | 511 | // Trim texts to avoid having false negatives when the title is surrounded by spaces or tabs |
| 512 | 512 | if (trim($hTag->nodeValue) === trim($curTitle)) { |
| 513 | 513 | $match = true; |
@@ -579,17 +579,17 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | // Scheme-rooted relative URI. |
| 581 | 581 | if (substr($uri, 0, 2) === '//') { |
| 582 | - return $scheme . '://' . substr($uri, 2); |
|
| 582 | + return $scheme.'://'.substr($uri, 2); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | // Prepath-rooted relative URI. |
| 586 | 586 | if (substr($uri, 0, 1) === '/') { |
| 587 | - return $prePath . $uri; |
|
| 587 | + return $prePath.$uri; |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | // Dotslash relative URI. |
| 591 | 591 | if (strpos($uri, './') === 0) { |
| 592 | - return $pathBase . substr($uri, 2); |
|
| 592 | + return $pathBase.substr($uri, 2); |
|
| 593 | 593 | } |
| 594 | 594 | // Ignore hash URIs: |
| 595 | 595 | if (substr($uri, 0, 1) === '#') { |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | // Standard relative URI; add entire path. pathBase already includes a |
| 600 | 600 | // trailing "/". |
| 601 | - return $pathBase . $uri; |
|
| 601 | + return $pathBase.$uri; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -614,17 +614,17 @@ discard block |
||
| 614 | 614 | if ($this->dom->baseURI !== null) { |
| 615 | 615 | if (substr($this->dom->baseURI, 0, 1) === '/') { |
| 616 | 616 | // URLs starting with '/' override completely the URL defined in the link |
| 617 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . $this->dom->baseURI; |
|
| 617 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).$this->dom->baseURI; |
|
| 618 | 618 | } else { |
| 619 | 619 | // Otherwise just prepend the base to the actual path |
| 620 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/' . rtrim($this->dom->baseURI, '/') . '/'; |
|
| 620 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).dirname(parse_url($url, PHP_URL_PATH)).'/'.rtrim($this->dom->baseURI, '/').'/'; |
|
| 621 | 621 | } |
| 622 | 622 | } else { |
| 623 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/'; |
|
| 623 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).dirname(parse_url($url, PHP_URL_PATH)).'/'; |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | $scheme = parse_url($pathBase, PHP_URL_SCHEME); |
| 627 | - $prePath = $scheme . '://' . parse_url($pathBase, PHP_URL_HOST); |
|
| 627 | + $prePath = $scheme.'://'.parse_url($pathBase, PHP_URL_HOST); |
|
| 628 | 628 | |
| 629 | 629 | return [$pathBase, $scheme, $prePath]; |
| 630 | 630 | } |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | continue; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - $matchString = $node->getAttribute('class') . ' ' . $node->getAttribute('id'); |
|
| 661 | + $matchString = $node->getAttribute('class').' '.$node->getAttribute('id'); |
|
| 662 | 662 | |
| 663 | 663 | if (!$node->isProbablyVisible()) { |
| 664 | 664 | $this->logger->debug(sprintf('[Get Nodes] Removing hidden node... Match string was: \'%s\'', $matchString)); |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | while ($parentOfTopCandidate->nodeName !== 'body' && $parentOfTopCandidate->nodeType === XML_ELEMENT_NODE) { |
| 1050 | 1050 | $listsContainingThisAncestor = 0; |
| 1051 | 1051 | for ($ancestorIndex = 0; $ancestorIndex < count($alternativeCandidateAncestors) && $listsContainingThisAncestor < $MINIMUM_TOPCANDIDATES; $ancestorIndex++) { |
| 1052 | - $listsContainingThisAncestor += (int)in_array($parentOfTopCandidate, $alternativeCandidateAncestors[$ancestorIndex]); |
|
| 1052 | + $listsContainingThisAncestor += (int) in_array($parentOfTopCandidate, $alternativeCandidateAncestors[$ancestorIndex]); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | if ($listsContainingThisAncestor >= $MINIMUM_TOPCANDIDATES) { |
| 1055 | 1055 | $topCandidate = $parentOfTopCandidate; |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | $row = $tbody->getFirstElementChild(); |
| 1286 | 1286 | if ($row->hasSingleTagInsideElement('td')) { |
| 1287 | 1287 | $cell = $row->getFirstElementChild(); |
| 1288 | - $cell = NodeUtility::setNodeTag($cell, (array_reduce(iterator_to_array($cell->childNodes), function ($carry, $node) { |
|
| 1288 | + $cell = NodeUtility::setNodeTag($cell, (array_reduce(iterator_to_array($cell->childNodes), function($carry, $node) { |
|
| 1289 | 1289 | return $node->isPhrasingContent() && $carry; |
| 1290 | 1290 | }, true)) ? 'p' : 'div'); |
| 1291 | 1291 | $table->parentNode->replaceChild($cell, $table); |
@@ -1465,7 +1465,7 @@ discard block |
||
| 1465 | 1465 | $node = $DOMNodeList->item($length - 1 - $i); |
| 1466 | 1466 | |
| 1467 | 1467 | // First check if we're in a data table, in which case don't remove us. |
| 1468 | - if ($node->hasAncestorTag('table', -1, function ($node) { |
|
| 1468 | + if ($node->hasAncestorTag('table', -1, function($node) { |
|
| 1469 | 1469 | return $node->isReadabilityDataTable(); |
| 1470 | 1470 | })) { |
| 1471 | 1471 | continue; |
@@ -1577,7 +1577,7 @@ discard block |
||
| 1577 | 1577 | public function _cleanHeaders(DOMDocument $article) |
| 1578 | 1578 | { |
| 1579 | 1579 | for ($headerIndex = 1; $headerIndex < 3; $headerIndex++) { |
| 1580 | - $headers = $article->getElementsByTagName('h' . $headerIndex); |
|
| 1580 | + $headers = $article->getElementsByTagName('h'.$headerIndex); |
|
| 1581 | 1581 | /** @var $header DOMElement */ |
| 1582 | 1582 | foreach ($headers as $header) { |
| 1583 | 1583 | $weight = 0; |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | global $fetch_last_error_content; |
| 16 | 16 | |
| 17 | - if (!$res && $fetch_last_error_content) |
|
| 18 | - $res = $fetch_last_error_content; |
|
| 17 | + if (!$res && $fetch_last_error_content) { |
|
| 18 | + $res = $fetch_last_error_content; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | $doc = new DOMDocument(); |
| 21 | 22 | |
@@ -1,36 +1,36 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Whomp extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Whomp!"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Whomp!"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["guid"], "whompcomic.com") !== false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["guid"], "whompcomic.com") !== false) { |
|
| 10 | 10 | |
| 11 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 12 | - false, false, 0, |
|
| 13 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 11 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 12 | + false, false, 0, |
|
| 13 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 14 | 14 | |
| 15 | - global $fetch_last_error_content; |
|
| 15 | + global $fetch_last_error_content; |
|
| 16 | 16 | |
| 17 | - if (!$res && $fetch_last_error_content) |
|
| 18 | - $res = $fetch_last_error_content; |
|
| 17 | + if (!$res && $fetch_last_error_content) |
|
| 18 | + $res = $fetch_last_error_content; |
|
| 19 | 19 | |
| 20 | - $doc = new DOMDocument(); |
|
| 20 | + $doc = new DOMDocument(); |
|
| 21 | 21 | |
| 22 | - if (@$doc->loadHTML($res)) { |
|
| 23 | - $xpath = new DOMXPath($doc); |
|
| 24 | - $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); |
|
| 22 | + if (@$doc->loadHTML($res)) { |
|
| 23 | + $xpath = new DOMXPath($doc); |
|
| 24 | + $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); |
|
| 25 | 25 | |
| 26 | - if ($basenode) { |
|
| 27 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 28 | - } |
|
| 29 | - } |
|
| 26 | + if ($basenode) { |
|
| 27 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - return true; |
|
| 32 | - } |
|
| 31 | + return true; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return false; |
|
| 35 | - } |
|
| 34 | + return false; |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -15,8 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | global $fetch_last_error_content; |
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) { |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $doc = new DOMDocument(); |
| 22 | 23 | |
@@ -1,38 +1,38 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_DarkLegacy extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Dark Legacy Comics"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Dark Legacy Comics"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | 9 | |
| 10 | - if (strpos($article["guid"], "darklegacycomics.com") !== false) { |
|
| 10 | + if (strpos($article["guid"], "darklegacycomics.com") !== false) { |
|
| 11 | 11 | |
| 12 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 13 | - false, false, 0, |
|
| 14 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 12 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 13 | + false, false, 0, |
|
| 14 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 15 | 15 | |
| 16 | - global $fetch_last_error_content; |
|
| 16 | + global $fetch_last_error_content; |
|
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | 20 | |
| 21 | - $doc = new DOMDocument(); |
|
| 21 | + $doc = new DOMDocument(); |
|
| 22 | 22 | |
| 23 | - if (@$doc->loadHTML($res)) { |
|
| 24 | - $xpath = new DOMXPath($doc); |
|
| 25 | - $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
| 23 | + if (@$doc->loadHTML($res)) { |
|
| 24 | + $xpath = new DOMXPath($doc); |
|
| 25 | + $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
| 26 | 26 | |
| 27 | - if ($basenode) { |
|
| 27 | + if ($basenode) { |
|
| 28 | 28 | |
| 29 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 30 | - } |
|
| 31 | - } |
|
| 29 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - return true; |
|
| 34 | - } |
|
| 33 | + return true; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return false; |
|
| 37 | - } |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | $i->parentNode->removeChild($i); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ($basenode){ |
|
| 57 | + if ($basenode) { |
|
| 58 | 58 | $article["content"] = $doc->saveHTML($basenode); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -46,8 +46,9 @@ |
||
| 46 | 46 | |
| 47 | 47 | $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
| 48 | 48 | |
| 49 | - if ($basenode) |
|
| 50 | - $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 49 | + if ($basenode) { |
|
| 50 | + $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
| 53 | 54 | foreach ($uninteresting as $i) { |
@@ -1,67 +1,67 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Pa extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Penny Arcade"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Penny Arcade"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
| 10 | 10 | |
| 11 | - $doc = new DOMDocument(); |
|
| 11 | + $doc = new DOMDocument(); |
|
| 12 | 12 | |
| 13 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 14 | - $xpath = new DOMXPath($doc); |
|
| 15 | - $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
| 13 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 14 | + $xpath = new DOMXPath($doc); |
|
| 15 | + $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
| 16 | 16 | |
| 17 | - if ($basenode) { |
|
| 18 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 19 | - } |
|
| 20 | - } |
|
| 17 | + if ($basenode) { |
|
| 18 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - return true; |
|
| 23 | - } |
|
| 22 | + return true; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
| 26 | - $doc = new DOMDocument(); |
|
| 25 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
| 26 | + $doc = new DOMDocument(); |
|
| 27 | 27 | |
| 28 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 29 | - $xpath = new DOMXPath($doc); |
|
| 30 | - $entries = $xpath->query('(//div[@class="post"])'); |
|
| 28 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 29 | + $xpath = new DOMXPath($doc); |
|
| 30 | + $entries = $xpath->query('(//div[@class="post"])'); |
|
| 31 | 31 | |
| 32 | - $basenode = false; |
|
| 32 | + $basenode = false; |
|
| 33 | 33 | |
| 34 | - foreach ($entries as $entry) { |
|
| 35 | - $basenode = $entry; |
|
| 36 | - } |
|
| 34 | + foreach ($entries as $entry) { |
|
| 35 | + $basenode = $entry; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
| 39 | - if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
| 38 | + $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
| 39 | + if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
| 40 | 40 | |
| 41 | - $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
| 42 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 41 | + $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
| 42 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 43 | 43 | |
| 44 | - $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
| 45 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 44 | + $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
| 45 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 46 | 46 | |
| 47 | - $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
|
| 47 | + $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
|
| 48 | 48 | |
| 49 | - if ($basenode) |
|
| 50 | - $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 49 | + if ($basenode) |
|
| 50 | + $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 51 | 51 | |
| 52 | - $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
| 53 | - foreach ($uninteresting as $i) { |
|
| 54 | - $i->parentNode->removeChild($i); |
|
| 55 | - } |
|
| 52 | + $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
| 53 | + foreach ($uninteresting as $i) { |
|
| 54 | + $i->parentNode->removeChild($i); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - if ($basenode){ |
|
| 58 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 59 | - } |
|
| 60 | - } |
|
| 57 | + if ($basenode){ |
|
| 58 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return true; |
|
| 63 | - } |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return false; |
|
| 66 | - } |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -17,8 +17,9 @@ |
||
| 17 | 17 | false, false, 0, |
| 18 | 18 | "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
| 19 | 19 | |
| 20 | - if (!$res && $fetch_last_error_content) |
|
| 21 | - $res = $fetch_last_error_content; |
|
| 20 | + if (!$res && $fetch_last_error_content) { |
|
| 21 | + $res = $fetch_last_error_content; |
|
| 22 | + } |
|
| 22 | 23 | |
| 23 | 24 | if (@$doc->loadHTML($res)) { |
| 24 | 25 | $xpath = new DOMXPath($doc); |
@@ -1,39 +1,39 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Cad extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Ctrl+Alt+Del"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Ctrl+Alt+Del"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["link"], "cad-comic.com") !== false) { |
|
| 10 | - if (strpos($article["title"], "News:") === false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["link"], "cad-comic.com") !== false) { |
|
| 10 | + if (strpos($article["title"], "News:") === false) { |
|
| 11 | 11 | |
| 12 | - global $fetch_last_error_content; |
|
| 12 | + global $fetch_last_error_content; |
|
| 13 | 13 | |
| 14 | - $doc = new DOMDocument(); |
|
| 14 | + $doc = new DOMDocument(); |
|
| 15 | 15 | |
| 16 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 17 | - false, false, 0, |
|
| 18 | - "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 16 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 17 | + false, false, 0, |
|
| 18 | + "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 19 | 19 | |
| 20 | - if (!$res && $fetch_last_error_content) |
|
| 21 | - $res = $fetch_last_error_content; |
|
| 20 | + if (!$res && $fetch_last_error_content) |
|
| 21 | + $res = $fetch_last_error_content; |
|
| 22 | 22 | |
| 23 | - if (@$doc->loadHTML($res)) { |
|
| 24 | - $xpath = new DOMXPath($doc); |
|
| 25 | - $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); |
|
| 23 | + if (@$doc->loadHTML($res)) { |
|
| 24 | + $xpath = new DOMXPath($doc); |
|
| 25 | + $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); |
|
| 26 | 26 | |
| 27 | - if ($basenode) { |
|
| 28 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 29 | - } |
|
| 30 | - } |
|
| 27 | + if ($basenode) { |
|
| 28 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return true; |
|
| 35 | - } |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return false; |
|
| 38 | - } |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | foreach ($matches as $tag) { |
| 38 | 38 | // Only strings starting with a number sign are considered tags |
| 39 | - if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 39 | + if (substr($tag->textContent, 0, 1) == '#') { |
|
| 40 | 40 | $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // Add comic title to article type if not empty (mostly Sunday strips) |
| 56 | 56 | if ($comic_title) { |
| 57 | - $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 57 | + $article["title"] = $article["title"]." - ".$comic_title; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!empty($tags)) { |
@@ -15,8 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | global $fetch_last_error_content; |
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) { |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $doc = new DOMDocument(); |
| 22 | 23 | |
@@ -2,72 +2,72 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Af_Comics_Dilbert extends Af_ComicFilter { |
| 4 | 4 | |
| 5 | - public function supported() { |
|
| 6 | - return array("Dilbert"); |
|
| 7 | - } |
|
| 5 | + public function supported() { |
|
| 6 | + return array("Dilbert"); |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public function process(&$article) { |
|
| 10 | - if (strpos($article["link"], "dilbert.com") !== false || |
|
| 11 | - strpos($article["link"], "/DilbertDailyStrip") !== false) { |
|
| 9 | + public function process(&$article) { |
|
| 10 | + if (strpos($article["link"], "dilbert.com") !== false || |
|
| 11 | + strpos($article["link"], "/DilbertDailyStrip") !== false) { |
|
| 12 | 12 | |
| 13 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 14 | - false, false, 0, |
|
| 15 | - "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 13 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 14 | + false, false, 0, |
|
| 15 | + "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 16 | 16 | |
| 17 | - global $fetch_last_error_content; |
|
| 17 | + global $fetch_last_error_content; |
|
| 18 | 18 | |
| 19 | - if (!$res && $fetch_last_error_content) |
|
| 20 | - $res = $fetch_last_error_content; |
|
| 19 | + if (!$res && $fetch_last_error_content) |
|
| 20 | + $res = $fetch_last_error_content; |
|
| 21 | 21 | |
| 22 | - $doc = new DOMDocument(); |
|
| 22 | + $doc = new DOMDocument(); |
|
| 23 | 23 | |
| 24 | - if (@$doc->loadHTML($res)) { |
|
| 25 | - $xpath = new DOMXPath($doc); |
|
| 24 | + if (@$doc->loadHTML($res)) { |
|
| 25 | + $xpath = new DOMXPath($doc); |
|
| 26 | 26 | |
| 27 | - // Get the image container |
|
| 28 | - $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); |
|
| 27 | + // Get the image container |
|
| 28 | + $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); |
|
| 29 | 29 | |
| 30 | - // Get the comic title |
|
| 31 | - $comic_title = $xpath->query('(//span[@class="comic-title-name"])')->item(0)->textContent; |
|
| 30 | + // Get the comic title |
|
| 31 | + $comic_title = $xpath->query('(//span[@class="comic-title-name"])')->item(0)->textContent; |
|
| 32 | 32 | |
| 33 | - // Get tags from the article |
|
| 34 | - $matches = $xpath->query('(//p[contains(@class, "comic-tags")][1]//a)'); |
|
| 35 | - $tags = array(); |
|
| 33 | + // Get tags from the article |
|
| 34 | + $matches = $xpath->query('(//p[contains(@class, "comic-tags")][1]//a)'); |
|
| 35 | + $tags = array(); |
|
| 36 | 36 | |
| 37 | - foreach ($matches as $tag) { |
|
| 38 | - // Only strings starting with a number sign are considered tags |
|
| 39 | - if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 40 | - $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 37 | + foreach ($matches as $tag) { |
|
| 38 | + // Only strings starting with a number sign are considered tags |
|
| 39 | + if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 40 | + $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // Get the current comics transcript and set it |
|
| 45 | - // as the title so it will be visible on mousover |
|
| 46 | - $transcript = $xpath->query('(//div[starts-with(@id, "js-toggle-transcript-")]//p)')->item(0); |
|
| 47 | - if ($transcript) { |
|
| 48 | - $basenode->setAttribute("title", $transcript->textContent); |
|
| 49 | - } |
|
| 44 | + // Get the current comics transcript and set it |
|
| 45 | + // as the title so it will be visible on mousover |
|
| 46 | + $transcript = $xpath->query('(//div[starts-with(@id, "js-toggle-transcript-")]//p)')->item(0); |
|
| 47 | + if ($transcript) { |
|
| 48 | + $basenode->setAttribute("title", $transcript->textContent); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($basenode) { |
|
| 52 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 53 | - } |
|
| 51 | + if ($basenode) { |
|
| 52 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // Add comic title to article type if not empty (mostly Sunday strips) |
|
| 56 | - if ($comic_title) { |
|
| 57 | - $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 58 | - } |
|
| 55 | + // Add comic title to article type if not empty (mostly Sunday strips) |
|
| 56 | + if ($comic_title) { |
|
| 57 | + $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!empty($tags)) { |
|
| 61 | - // Ignore existing tags and just replace them all |
|
| 62 | - $article["tags"] = array_unique($tags); |
|
| 63 | - } |
|
| 60 | + if (!empty($tags)) { |
|
| 61 | + // Ignore existing tags and just replace them all |
|
| 62 | + $article["tags"] = array_unique($tags); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return true; |
|
| 68 | - } |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return false; |
|
| 71 | - } |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | ?> |
@@ -17,11 +17,13 @@ discard block |
||
| 17 | 17 | $this->host = $host; |
| 18 | 18 | $this->cache = new DiskCache("starred-images"); |
| 19 | 19 | |
| 20 | - if ($this->cache->makeDir()) |
|
| 21 | - chmod($this->cache->getDir(), 0777); |
|
| 20 | + if ($this->cache->makeDir()) { |
|
| 21 | + chmod($this->cache->getDir(), 0777); |
|
| 22 | + } |
|
| 22 | 23 | |
| 23 | - if (!$this->cache->exists(".no-auto-expiry")) |
|
| 24 | - $this->cache->touch(".no-auto-expiry"); |
|
| 24 | + if (!$this->cache->exists(".no-auto-expiry")) { |
|
| 25 | + $this->cache->touch(".no-auto-expiry"); |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | if ($this->cache->isWritable()) { |
| 27 | 29 | $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); |
@@ -141,8 +143,10 @@ discard block |
||
| 141 | 143 | |
| 142 | 144 | $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
| 143 | 145 | |
| 144 | - if ($data) |
|
| 145 | - return $this->cache->put($local_filename, $data);; |
|
| 146 | + if ($data) { |
|
| 147 | + return $this->cache->put($local_filename, $data); |
|
| 148 | + } |
|
| 149 | + ; |
|
| 146 | 150 | |
| 147 | 151 | } else { |
| 148 | 152 | //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
@@ -167,10 +171,11 @@ discard block |
||
| 167 | 171 | |
| 168 | 172 | Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
| 169 | 173 | |
| 170 | - if ($this->cache->exists($status_filename)) |
|
| 171 | - $status = json_decode($this->cache->get($status_filename), true); |
|
| 172 | - else |
|
| 173 | - $status = []; |
|
| 174 | + if ($this->cache->exists($status_filename)) { |
|
| 175 | + $status = json_decode($this->cache->get($status_filename), true); |
|
| 176 | + } else { |
|
| 177 | + $status = []; |
|
| 178 | + } |
|
| 174 | 179 | |
| 175 | 180 | $status["attempt"] += 1; |
| 176 | 181 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function hook_house_keeping() { |
| 36 | 36 | /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
| 37 | 37 | |
| 38 | - Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); |
|
| 38 | + Debug::log("caching media of starred articles for user ".$this->host->get_owner_uid()."..."); |
|
| 39 | 39 | |
| 40 | 40 | $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
| 41 | 41 | ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
| 54 | 54 | |
| 55 | 55 | while ($line = $sth->fetch()) { |
| 56 | - Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE); |
|
| 56 | + Debug::log("processing article ".$line["title"], Debug::$LOG_VERBOSE); |
|
| 57 | 57 | |
| 58 | 58 | if ($line["site_url"]) { |
| 59 | 59 | $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
| 60 | 60 | |
| 61 | 61 | if ($success) { |
| 62 | - $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"]; |
|
| 62 | + $plugin_data = "starred_cache_images,${line['owner_uid']}:".$line["plugin_data"]; |
|
| 63 | 63 | |
| 64 | 64 | $usth->execute([$plugin_data, $line['id']]); |
| 65 | 65 | } |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | /* actual housekeeping */ |
| 71 | 71 | |
| 72 | - Debug::log("expiring " . $this->cache->getDir() . "..."); |
|
| 72 | + Debug::log("expiring ".$this->cache->getDir()."..."); |
|
| 73 | 73 | |
| 74 | - $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE); |
|
| 74 | + $files = glob($this->cache->getDir()."/*.{png,mp4,status}", GLOB_BRACE); |
|
| 75 | 75 | |
| 76 | 76 | $last_article_id = 0; |
| 77 | 77 | $article_exists = 1; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function hook_enclosure_entry($enc, $article_id) { |
| 98 | - $local_filename = $article_id . "-" . sha1($enc["content_url"]); |
|
| 98 | + $local_filename = $article_id."-".sha1($enc["content_url"]); |
|
| 99 | 99 | |
| 100 | 100 | if ($this->cache->exists($local_filename)) { |
| 101 | 101 | $enc["content_url"] = $this->cache->getUrl($local_filename); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if ($entry->hasAttribute('src')) { |
| 115 | 115 | $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
| 116 | 116 | |
| 117 | - $local_filename = $article_id . "-" . sha1($src); |
|
| 117 | + $local_filename = $article_id."-".sha1($src); |
|
| 118 | 118 | |
| 119 | 119 | if ($this->cache->exists($local_filename)) { |
| 120 | 120 | $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | private function cache_url($article_id, $url) { |
| 131 | - $local_filename = $article_id . "-" . sha1($url); |
|
| 131 | + $local_filename = $article_id."-".sha1($url); |
|
| 132 | 132 | |
| 133 | 133 | if (!$this->cache->exists($local_filename)) { |
| 134 | 134 | Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
| 137 | 137 | |
| 138 | 138 | if ($data) |
| 139 | - return $this->cache->put($local_filename, $data);; |
|
| 139 | + return $this->cache->put($local_filename, $data); ; |
|
| 140 | 140 | |
| 141 | 141 | } else { |
| 142 | 142 | //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
| 151 | - $status_filename = $article_id . "-" . sha1($site_url) . ".status"; |
|
| 151 | + $status_filename = $article_id."-".sha1($site_url).".status"; |
|
| 152 | 152 | |
| 153 | 153 | /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
| 154 | 154 | if (!$this->cache->isWritable($status_filename)) { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $has_images = false; |
| 182 | 182 | $success = false; |
| 183 | 183 | |
| 184 | - if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) { |
|
| 184 | + if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) { |
|
| 185 | 185 | $xpath = new DOMXPath($doc); |
| 186 | 186 | $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
| 187 | 187 | |
@@ -1,43 +1,43 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Cache_Starred_Images extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 6 | - /* @var DiskCache $cache */ |
|
| 7 | - private $cache; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | + /* @var DiskCache $cache */ |
|
| 7 | + private $cache; |
|
| 8 | 8 | private $max_cache_attempts = 5; // per-article |
| 9 | 9 | |
| 10 | - public function about() { |
|
| 11 | - return array(1.0, |
|
| 12 | - "Automatically cache media files in Starred articles", |
|
| 13 | - "fox"); |
|
| 14 | - } |
|
| 10 | + public function about() { |
|
| 11 | + return array(1.0, |
|
| 12 | + "Automatically cache media files in Starred articles", |
|
| 13 | + "fox"); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function init($host) { |
|
| 17 | - $this->host = $host; |
|
| 18 | - $this->cache = new DiskCache("starred-images"); |
|
| 16 | + public function init($host) { |
|
| 17 | + $this->host = $host; |
|
| 18 | + $this->cache = new DiskCache("starred-images"); |
|
| 19 | 19 | |
| 20 | - if ($this->cache->makeDir()) |
|
| 21 | - chmod($this->cache->getDir(), 0777); |
|
| 20 | + if ($this->cache->makeDir()) |
|
| 21 | + chmod($this->cache->getDir(), 0777); |
|
| 22 | 22 | |
| 23 | - if (!$this->cache->exists(".no-auto-expiry")) |
|
| 24 | - $this->cache->touch(".no-auto-expiry"); |
|
| 23 | + if (!$this->cache->exists(".no-auto-expiry")) |
|
| 24 | + $this->cache->touch(".no-auto-expiry"); |
|
| 25 | 25 | |
| 26 | - if ($this->cache->isWritable()) { |
|
| 27 | - $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); |
|
| 28 | - $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 29 | - $host->add_hook($host::HOOK_SANITIZE, $this); |
|
| 30 | - } else { |
|
| 31 | - user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING); |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | + if ($this->cache->isWritable()) { |
|
| 27 | + $host->add_hook($host::HOOK_HOUSE_KEEPING, $this); |
|
| 28 | + $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); |
|
| 29 | + $host->add_hook($host::HOOK_SANITIZE, $this); |
|
| 30 | + } else { |
|
| 31 | + user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function hook_house_keeping() { |
|
| 36 | - /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
|
| 35 | + public function hook_house_keeping() { |
|
| 36 | + /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
|
| 37 | 37 | |
| 38 | - Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); |
|
| 38 | + Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); |
|
| 39 | 39 | |
| 40 | - $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
|
| 40 | + $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
|
| 41 | 41 | ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data |
| 42 | 42 | FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON |
| 43 | 43 | (ttrss_user_entries.feed_id = ttrss_feeds.id) |
@@ -48,115 +48,115 @@ discard block |
||
| 48 | 48 | plugin_data NOT LIKE '%starred_cache_images%' |
| 49 | 49 | ORDER BY ".sql_random_function()." LIMIT 100"); |
| 50 | 50 | |
| 51 | - if ($sth->execute([$this->host->get_owner_uid()])) { |
|
| 51 | + if ($sth->execute([$this->host->get_owner_uid()])) { |
|
| 52 | 52 | |
| 53 | - $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
|
| 53 | + $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
|
| 54 | 54 | |
| 55 | - while ($line = $sth->fetch()) { |
|
| 56 | - Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE); |
|
| 55 | + while ($line = $sth->fetch()) { |
|
| 56 | + Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE); |
|
| 57 | 57 | |
| 58 | - if ($line["site_url"]) { |
|
| 59 | - $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
|
| 58 | + if ($line["site_url"]) { |
|
| 59 | + $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
|
| 60 | 60 | |
| 61 | - if ($success) { |
|
| 62 | - $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"]; |
|
| 61 | + if ($success) { |
|
| 62 | + $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"]; |
|
| 63 | 63 | |
| 64 | - $usth->execute([$plugin_data, $line['id']]); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 64 | + $usth->execute([$plugin_data, $line['id']]); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /* actual housekeeping */ |
|
| 70 | + /* actual housekeeping */ |
|
| 71 | 71 | |
| 72 | - Debug::log("expiring " . $this->cache->getDir() . "..."); |
|
| 72 | + Debug::log("expiring " . $this->cache->getDir() . "..."); |
|
| 73 | 73 | |
| 74 | - $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE); |
|
| 74 | + $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE); |
|
| 75 | 75 | |
| 76 | - $last_article_id = 0; |
|
| 77 | - $article_exists = 1; |
|
| 76 | + $last_article_id = 0; |
|
| 77 | + $article_exists = 1; |
|
| 78 | 78 | |
| 79 | - foreach ($files as $file) { |
|
| 80 | - list ($article_id, $hash) = explode("-", basename($file)); |
|
| 79 | + foreach ($files as $file) { |
|
| 80 | + list ($article_id, $hash) = explode("-", basename($file)); |
|
| 81 | 81 | |
| 82 | - if ($article_id != $last_article_id) { |
|
| 83 | - $last_article_id = $article_id; |
|
| 82 | + if ($article_id != $last_article_id) { |
|
| 83 | + $last_article_id = $article_id; |
|
| 84 | 84 | |
| 85 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?"); |
|
| 86 | - $sth->execute([$article_id]); |
|
| 85 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?"); |
|
| 86 | + $sth->execute([$article_id]); |
|
| 87 | 87 | |
| 88 | - $article_exists = $sth->fetch(); |
|
| 89 | - } |
|
| 88 | + $article_exists = $sth->fetch(); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - if (!$article_exists) { |
|
| 92 | - unlink($file); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 91 | + if (!$article_exists) { |
|
| 92 | + unlink($file); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function hook_enclosure_entry($enc, $article_id) { |
|
| 98 | - $local_filename = $article_id . "-" . sha1($enc["content_url"]); |
|
| 97 | + public function hook_enclosure_entry($enc, $article_id) { |
|
| 98 | + $local_filename = $article_id . "-" . sha1($enc["content_url"]); |
|
| 99 | 99 | |
| 100 | - if ($this->cache->exists($local_filename)) { |
|
| 101 | - $enc["content_url"] = $this->cache->getUrl($local_filename); |
|
| 102 | - } |
|
| 100 | + if ($this->cache->exists($local_filename)) { |
|
| 101 | + $enc["content_url"] = $this->cache->getUrl($local_filename); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - return $enc; |
|
| 105 | - } |
|
| 104 | + return $enc; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { |
|
| 108 | - $xpath = new DOMXpath($doc); |
|
| 107 | + public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { |
|
| 108 | + $xpath = new DOMXpath($doc); |
|
| 109 | 109 | |
| 110 | - if ($article_id) { |
|
| 111 | - $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 110 | + if ($article_id) { |
|
| 111 | + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 112 | 112 | |
| 113 | - foreach ($entries as $entry) { |
|
| 114 | - if ($entry->hasAttribute('src')) { |
|
| 115 | - $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 113 | + foreach ($entries as $entry) { |
|
| 114 | + if ($entry->hasAttribute('src')) { |
|
| 115 | + $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 116 | 116 | |
| 117 | - $local_filename = $article_id . "-" . sha1($src); |
|
| 117 | + $local_filename = $article_id . "-" . sha1($src); |
|
| 118 | 118 | |
| 119 | - if ($this->cache->exists($local_filename)) { |
|
| 120 | - $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
|
| 121 | - $entry->removeAttribute("srcset"); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - } |
|
| 119 | + if ($this->cache->exists($local_filename)) { |
|
| 120 | + $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
|
| 121 | + $entry->removeAttribute("srcset"); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return $doc; |
|
| 128 | - } |
|
| 127 | + return $doc; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - private function cache_url($article_id, $url) { |
|
| 131 | - $local_filename = $article_id . "-" . sha1($url); |
|
| 130 | + private function cache_url($article_id, $url) { |
|
| 131 | + $local_filename = $article_id . "-" . sha1($url); |
|
| 132 | 132 | |
| 133 | - if (!$this->cache->exists($local_filename)) { |
|
| 134 | - Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
|
| 133 | + if (!$this->cache->exists($local_filename)) { |
|
| 134 | + Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
|
| 135 | 135 | |
| 136 | - $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 136 | + $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
|
| 137 | 137 | |
| 138 | - if ($data) |
|
| 139 | - return $this->cache->put($local_filename, $data);; |
|
| 138 | + if ($data) |
|
| 139 | + return $this->cache->put($local_filename, $data);; |
|
| 140 | 140 | |
| 141 | - } else { |
|
| 142 | - //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
|
| 141 | + } else { |
|
| 142 | + //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
|
| 143 | 143 | |
| 144 | - return true; |
|
| 145 | - } |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return false; |
|
| 148 | - } |
|
| 147 | + return false; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
|
| 151 | - $status_filename = $article_id . "-" . sha1($site_url) . ".status"; |
|
| 150 | + private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
|
| 151 | + $status_filename = $article_id . "-" . sha1($site_url) . ".status"; |
|
| 152 | 152 | |
| 153 | - /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
|
| 154 | - if (!$this->cache->isWritable($status_filename)) { |
|
| 155 | - Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE); |
|
| 156 | - return false; |
|
| 157 | - } |
|
| 153 | + /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
|
| 154 | + if (!$this->cache->isWritable($status_filename)) { |
|
| 155 | + Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE); |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
|
| 159 | + Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
|
| 160 | 160 | |
| 161 | 161 | if ($this->cache->exists($status_filename)) |
| 162 | 162 | $status = json_decode($this->cache->get($status_filename), true); |
@@ -176,49 +176,49 @@ discard block |
||
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $doc = new DOMDocument(); |
|
| 179 | + $doc = new DOMDocument(); |
|
| 180 | 180 | |
| 181 | - $has_images = false; |
|
| 182 | - $success = false; |
|
| 181 | + $has_images = false; |
|
| 182 | + $success = false; |
|
| 183 | 183 | |
| 184 | 184 | if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) { |
| 185 | - $xpath = new DOMXPath($doc); |
|
| 186 | - $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 185 | + $xpath = new DOMXPath($doc); |
|
| 186 | + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
|
| 187 | 187 | |
| 188 | - foreach ($entries as $entry) { |
|
| 188 | + foreach ($entries as $entry) { |
|
| 189 | 189 | |
| 190 | - if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) { |
|
| 190 | + if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) { |
|
| 191 | 191 | |
| 192 | - $has_images = true; |
|
| 192 | + $has_images = true; |
|
| 193 | 193 | |
| 194 | - $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 194 | + $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
|
| 195 | 195 | |
| 196 | - if ($this->cache_url($article_id, $src)) { |
|
| 197 | - $success = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 196 | + if ($this->cache_url($article_id, $src)) { |
|
| 197 | + $success = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND |
|
| 203 | + $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND |
|
| 204 | 204 | (content_type LIKE '%image%' OR content_type LIKE '%video%')"); |
| 205 | 205 | |
| 206 | 206 | if ($esth->execute([$article_id])) { |
| 207 | - while ($enc = $esth->fetch()) { |
|
| 207 | + while ($enc = $esth->fetch()) { |
|
| 208 | 208 | |
| 209 | - $has_images = true; |
|
| 210 | - $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 209 | + $has_images = true; |
|
| 210 | + $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 211 | 211 | |
| 212 | - if ($this->cache_url($article_id, $url)) { |
|
| 213 | - $success = true; |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - } |
|
| 212 | + if ($this->cache_url($article_id, $url)) { |
|
| 213 | + $success = true; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - return $success || !$has_images; |
|
| 219 | - } |
|
| 218 | + return $success || !$has_images; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - public function api_version() { |
|
| 222 | - return 2; |
|
| 223 | - } |
|
| 221 | + public function api_version() { |
|
| 222 | + return 2; |
|
| 223 | + } |
|
| 224 | 224 | } |
@@ -53,8 +53,9 @@ |
||
| 53 | 53 | |
| 54 | 54 | while ($line = $sth->fetch()) { |
| 55 | 55 | |
| 56 | - if (!$subject) |
|
| 57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 56 | + if (!$subject) { |
|
| 57 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 58 | + } |
|
| 58 | 59 | |
| 59 | 60 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
| 60 | 61 | $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function get_js() { |
| 18 | - return file_get_contents(dirname(__FILE__) . "/init.js"); |
|
| 18 | + return file_get_contents(dirname(__FILE__)."/init.js"); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function hook_article_button($line) { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
| 47 | 47 | |
| 48 | 48 | if (count($ids) > 1) { |
| 49 | - $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
| 49 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
| 50 | 50 | } else { |
| 51 | 51 | $subject = ""; |
| 52 | 52 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | while ($line = $sth->fetch()) { |
| 55 | 55 | |
| 56 | 56 | if (!$subject) |
| 57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 57 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
| 58 | 58 | |
| 59 | 59 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
| 60 | 60 | $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
@@ -1,95 +1,95 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class MailTo extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Share article via email (using mailto: links, invoking your mail client)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Share article via email (using mailto: links, invoking your mail client)", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function init($host) { |
|
| 12 | - $this->host = $host; |
|
| 11 | + public function init($host) { |
|
| 12 | + $this->host = $host; |
|
| 13 | 13 | |
| 14 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 15 | - } |
|
| 14 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function get_js() { |
|
| 18 | - return file_get_contents(dirname(__FILE__) . "/init.js"); |
|
| 19 | - } |
|
| 17 | + public function get_js() { |
|
| 18 | + return file_get_contents(dirname(__FILE__) . "/init.js"); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function hook_article_button($line) { |
|
| 22 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 21 | + public function hook_article_button($line) { |
|
| 22 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 23 | 23 | onclick=\"Plugins.Mailto.send(".$line["id"].")\" |
| 24 | 24 | title='".__('Forward by email')."'>mail_outline</i>"; |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function emailArticle() { |
|
| 27 | + public function emailArticle() { |
|
| 28 | 28 | |
| 29 | - $ids = explode(",", $_REQUEST['param']); |
|
| 30 | - $ids_qmarks = arr_qmarks($ids); |
|
| 29 | + $ids = explode(",", $_REQUEST['param']); |
|
| 30 | + $ids_qmarks = arr_qmarks($ids); |
|
| 31 | 31 | |
| 32 | - require_once "lib/MiniTemplator.class.php"; |
|
| 32 | + require_once "lib/MiniTemplator.class.php"; |
|
| 33 | 33 | |
| 34 | - $tpl = new MiniTemplator; |
|
| 34 | + $tpl = new MiniTemplator; |
|
| 35 | 35 | |
| 36 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 36 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 37 | 37 | |
| 38 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 39 | - //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 40 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 38 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 39 | + //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 40 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
| 43 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
| 44 | 44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
| 45 | 45 | id IN ($ids_qmarks) AND owner_uid = ?"); |
| 46 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 46 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 47 | 47 | |
| 48 | - if (count($ids) > 1) { |
|
| 49 | - $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
| 50 | - } else { |
|
| 51 | - $subject = ""; |
|
| 52 | - } |
|
| 48 | + if (count($ids) > 1) { |
|
| 49 | + $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
| 50 | + } else { |
|
| 51 | + $subject = ""; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - while ($line = $sth->fetch()) { |
|
| 54 | + while ($line = $sth->fetch()) { |
|
| 55 | 55 | |
| 56 | - if (!$subject) |
|
| 57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 56 | + if (!$subject) |
|
| 57 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
| 58 | 58 | |
| 59 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 60 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 59 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 60 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 61 | 61 | |
| 62 | - $tpl->addBlock('article'); |
|
| 63 | - } |
|
| 62 | + $tpl->addBlock('article'); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $tpl->addBlock('email'); |
|
| 65 | + $tpl->addBlock('email'); |
|
| 66 | 66 | |
| 67 | - $content = ""; |
|
| 68 | - $tpl->generateOutputToString($content); |
|
| 67 | + $content = ""; |
|
| 68 | + $tpl->generateOutputToString($content); |
|
| 69 | 69 | |
| 70 | - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
| 71 | - "&body=".rawurlencode($content)); |
|
| 70 | + $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
| 71 | + "&body=".rawurlencode($content)); |
|
| 72 | 72 | |
| 73 | - print __("Clicking the following link to invoke your mail client:"); |
|
| 73 | + print __("Clicking the following link to invoke your mail client:"); |
|
| 74 | 74 | |
| 75 | - print "<div class='panel text-center'>"; |
|
| 76 | - print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
| 77 | - __("Forward selected article(s) by email.")."</a>"; |
|
| 78 | - print "</div>"; |
|
| 75 | + print "<div class='panel text-center'>"; |
|
| 76 | + print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
| 77 | + __("Forward selected article(s) by email.")."</a>"; |
|
| 78 | + print "</div>"; |
|
| 79 | 79 | |
| 80 | - print __("You should be able to edit the message before sending in your mail client."); |
|
| 80 | + print __("You should be able to edit the message before sending in your mail client."); |
|
| 81 | 81 | |
| 82 | - print "<p>"; |
|
| 82 | + print "<p>"; |
|
| 83 | 83 | |
| 84 | - print "<footer class='text-center'>"; |
|
| 85 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
| 86 | - print "</footer>"; |
|
| 84 | + print "<footer class='text-center'>"; |
|
| 85 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
| 86 | + print "</footer>"; |
|
| 87 | 87 | |
| 88 | - //return; |
|
| 89 | - } |
|
| 88 | + //return; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public function api_version() { |
|
| 92 | - return 2; |
|
| 93 | - } |
|
| 91 | + public function api_version() { |
|
| 92 | + return 2; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | $doc = new DOMDocument(); |
| 21 | 21 | |
| 22 | - @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 22 | + @$doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]); |
|
| 23 | 23 | |
| 24 | 24 | if ($doc) { |
| 25 | 25 | $xpath = new DOMXPath($doc); |
@@ -1,47 +1,47 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Fsckportal extends Plugin { |
| 3 | 3 | |
| 4 | - private $host; |
|
| 4 | + private $host; |
|
| 5 | 5 | |
| 6 | - public function about() { |
|
| 7 | - return array(1.0, |
|
| 8 | - "Remove feedsportal spamlinks from article content", |
|
| 9 | - "fox"); |
|
| 10 | - } |
|
| 6 | + public function about() { |
|
| 7 | + return array(1.0, |
|
| 8 | + "Remove feedsportal spamlinks from article content", |
|
| 9 | + "fox"); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function init($host) { |
|
| 13 | - $this->host = $host; |
|
| 12 | + public function init($host) { |
|
| 13 | + $this->host = $host; |
|
| 14 | 14 | |
| 15 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | - } |
|
| 15 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function hook_article_filter($article) { |
|
| 18 | + public function hook_article_filter($article) { |
|
| 19 | 19 | |
| 20 | - $doc = new DOMDocument(); |
|
| 20 | + $doc = new DOMDocument(); |
|
| 21 | 21 | |
| 22 | - @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 22 | + @$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
| 23 | 23 | |
| 24 | - if ($doc) { |
|
| 25 | - $xpath = new DOMXPath($doc); |
|
| 26 | - $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 24 | + if ($doc) { |
|
| 25 | + $xpath = new DOMXPath($doc); |
|
| 26 | + $entries = $xpath->query('(//img[@src]|//a[@href])'); |
|
| 27 | 27 | |
| 28 | - foreach ($entries as $entry) { |
|
| 29 | - if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | - $entry->parentNode->removeChild($entry); |
|
| 31 | - } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | - $entry->parentNode->removeChild($entry); |
|
| 33 | - } |
|
| 34 | - } |
|
| 28 | + foreach ($entries as $entry) { |
|
| 29 | + if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) { |
|
| 30 | + $entry->parentNode->removeChild($entry); |
|
| 31 | + } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) { |
|
| 32 | + $entry->parentNode->removeChild($entry); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $article["content"] = $doc->saveHTML(); |
|
| 36 | + $article["content"] = $doc->saveHTML(); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $article; |
|
| 41 | - } |
|
| 40 | + return $article; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function api_version() { |
|
| 44 | - return 2; |
|
| 45 | - } |
|
| 43 | + public function api_version() { |
|
| 44 | + return 2; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |