Esempio n. 1
0
 /**
  * Removes a path
  *
  * @param string $path
  */
 public function removePath($path)
 {
     $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $this->finder->removePath($path);
     if ($this->environment) {
         $this->finder->removePath($path . $this->environment);
     }
 }
Esempio n. 2
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'));
 }
Esempio n. 3
0
 /**
  * Gets the HTML to insert the assets of the given type and groupName.
  *
  * @param string $type      Type of asset to fetch
  * @param string $groupName Optional groupName name to fetch
  *
  * @return string
  *
  * @since 2.0
  */
 public function get($type, $groupName = null)
 {
     $group = $this->getGroup($type, $groupName);
     $typeInstance = $this->getType($type);
     // TODO: move file path fetching into filers so pre-processing can happen
     $tags = '';
     foreach ($group->getFiles() as $file) {
         // Get the path of the file
         $filePath = $this->finder->find($type . '/' . $file);
         // Copy that to our output directory if needed
         $outputDir = $this->docroot . '/' . $type;
         if (!is_dir($outputDir)) {
             mkdir($outputDir, 0777, true);
         }
         copy($filePath, $outputDir . '/' . $file);
         // Build the html tag
         $tags .= $typeInstance->wrapFile("//{$this->baseURL}/{$type}/{$file}");
     }
     return $tags;
 }
Esempio n. 4
0
 protected function addPath(ComponentInterface $component)
 {
     $this->finder->addPath($component->getPath());
 }
Esempio n. 5
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);
     }
 }
Esempio n. 6
0
 /**
  * Attempts to get the file name for the given view
  *
  * @param $view
  *
  * @return array|\Fuel\FileSystem\Directory|\Fuel\FileSystem\File|string
  */
 public function findView($view)
 {
     $view = $this->viewFolder . DIRECTORY_SEPARATOR . ltrim($view, DIRECTORY_SEPARATOR);
     return $this->finder->findFileReversed($view);
 }