Overview

Namespaces

  • FastFeed
    • Aggregator
    • Cache
    • Exception
    • Logger
    • Parser
    • Processor
  • PHP

Classes

  • ImageProcessor
  • ImagesProcessor
  • LimitProcessor
  • PathProcessor
  • RemoveStylesProcessor
  • SanitizerProcessor
  • SortByDateProcessor
  • StripTagsProcessor

Interfaces

  • ProcessorInterface
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * This file is part of the planetubuntu package.
 4:  *
 5:  * (c) Daniel González <daniel@desarrolla2.com>
 6:  *
 7:  * For the full copyright and license information, please view the LICENSE
 8:  * file that was distributed with this source code.
 9:  */
10: namespace FastFeed\Processor;
11: 
12: use FastFeed\Item;
13: use FastFeed\Url\Url;
14: 
15: /**
16:  * PathProcessor
17:  */
18: class PathProcessor implements ProcessorInterface
19: {
20:     /**
21:      * Execute processor
22:      *
23:      * @param array $items
24:      *
25:      * @return array $items
26:      */
27:     public function process(array $items)
28:     {
29:         foreach ($items as $key => $item) {
30:             $items[$key] = $this->fixPaths($item);
31:         }
32: 
33:         return $items;
34:     }
35: 
36:     /**
37:      * @param Item $item
38:      *
39:      * @return Item
40:      */
41:     protected function fixPaths(Item $item)
42:     {
43:         $url = new Url($item->getSource());
44:         $item->setIntro($this->getFixedText($item->getIntro(), $url->getFullHost()));
45:         $item->setContent($this->getFixedText($item->getContent(), $url->getFullHost()));
46: 
47:         return $item;
48:     }
49: 
50:     /**
51:      * @param $text
52:      * @param $domain
53:      *
54:      * @return mixed
55:      */
56:     protected function getFixedText($text, $domain)
57:     {
58:         $text = str_ireplace('href="/', 'href="' . $domain . '/', $text);
59:         $text = str_ireplace('href=\'/', 'href=\'' . $domain . '/', $text);
60:         $text = str_ireplace('src="/', 'src="' . $domain . '/', $text);
61:         $text = str_ireplace('src=\'/', 'src=\'' . $domain . '/', $text);
62: 
63:         return $text;
64:     }
65: }
66: 
API documentation generated by ApiGen 2.8.0