Example #1
0
 public function testFindHandler()
 {
     $f = new Finder();
     $f->addPath(__DIR__ . '/../resources/one');
     $f->returnHandlers();
     $this->assertInstanceOf('Fuel\\FileSystem\\File', $f->findFile('a'));
     $f = new Finder();
     $f->addPath(__DIR__ . '/../resources/one');
     $f->addPath(__DIR__ . '/../resources');
     $f->asHandlers();
     $this->assertInstanceOf('Fuel\\FileSystem\\File', $f->findFile('a'));
     $f->asHandlers();
     $this->assertInstanceOf('Fuel\\FileSystem\\Directory', $f->findDir('one'));
     $f->returnHandlers();
     $this->assertContainsOnlyInstancesOf('Fuel\\FileSystem\\File', $f->findAllFiles('a'));
     $this->assertContainsOnlyInstancesOf('Fuel\\FileSystem\\Directory', $f->findAllDirs('one'));
 }
Example #2
0
 /**
  * Processes HTML body
  *
  * @param Message $message
  *
  * @since 2.0
  */
 public function processHtml(Message $message)
 {
     $html = $message->getBody();
     // Remove html comments
     if ($this->config['email']['html']['remove_comments']) {
         $html = preg_replace('/<!--(.*)-->/', '', $html);
     }
     // Auto attach all images
     // TODO single or double quote
     if ($this->config['email']['attach']['auto']) {
         preg_match_all("/(src|background)=\"(.*)\"/Ui", $html, $images);
         if (empty($images[2]) === false) {
             // TODO Remove dependency
             $finder = new Finder($this->config['email']['attach']['paths'], null, $this->config['email']['attach']['root']);
             $finder->returnHandlers();
             foreach ($images[2] as $i => $imageUrl) {
                 // Don't attach absolute urls and already inline content
                 if (preg_match('/(^http\\:\\/\\/|^https\\:\\/\\/|^cid\\:|^data\\:|^#)/Ui', $imageUrl) === false) {
                     $file = $finder->findFile($imageUrl);
                     if ($file) {
                         $attachment = new $this->config['email']['attach']['class']($file);
                         $attachment->setInline();
                         $message->attach($attachment);
                         $cid = $attachment->getCid();
                         $html = preg_replace("/" . $images[1][$i] . "=\"" . preg_quote($imageUrl, '/') . "\"/Ui", $images[1][$i] . "=\"" . $cid . "\"", $html);
                     }
                 }
             }
         }
     }
     $message->setBody($html);
     if ($message->hasAltBody() === false and $this->config['email']['html']['generate_alt']) {
         $this->generateAlt($message);
     }
 }