/** * Gets all the files used by the provided CSS files * @param array $fileNames Array with the file names of CSS files * @return array Array with the path of the file as key and the File object as value */ protected function getFilesFromArray(array $fileNames) { $files = array(); $zibo = Zibo::getInstance(); foreach ($fileNames as $fileName) { $file = new File($fileName); if (!$file->isAbsolute()) { $file = $zibo->getFile($fileName); if (!$file) { continue; } } $styleFiles = $this->getFilesFromStyle($zibo, $file); $files = Structure::merge($files, $styleFiles); } return $files; }
/** * Construct a file object * @param string|File $path * @param string|File $child file in the provided path (optional) * @return null * @throws zibo\library\filesystem\exception\FileSystemException when the path is empty * @throws zibo\library\filesystem\exception\FileSystemException when the child is absolute */ public function __construct($path, $child = null) { $this->isRootPath = false; $this->path = self::retrievePath($path, $this->isRootPath); if ($child != null) { $child = new File($child); if ($child->isAbsolute()) { throw new FileSystemException('Child ' . $child->getPath() . ' cannot be absolute'); } $childPath = $child->getPath(); if ($child->hasPharProtocol()) { $childPath = substr($childPath, 7); } if (!$this->isRootPath) { $this->path .= self::DIRECTORY_SEPARATOR; } $this->path .= $childPath; } if ($this->isInPhar() && !$this->hasPharProtocol()) { $this->path = 'phar://' . $this->path; } }
/** * Process the source, apply thumbnailer if set * @param string $source source to process * @return string source to be used by the html of this image tag * @throws zibo\ZiboException when the source file could not be found */ private function processSource($source) { $fileSource = new File($source); if (!$fileSource->isAbsolute() && !String::startsWith($fileSource->getPath(), Zibo::DIRECTORY_APPLICATION . File::DIRECTORY_SEPARATOR)) { $fileSource = Zibo::getInstance()->getFile($fileSource->getPath()); if (!$fileSource) { throw new ZiboException('Could not find ' . $source); } } $fileDestination = $this->getCacheFile($fileSource); if (!$fileDestination->exists() || $fileSource->getModificationTime() > $fileDestination->getModificationTime()) { $image = new CoreImage($fileSource); if ($this->thumbnailer) { $thumbnail = $image->thumbnail($this->thumbnailer, $this->thumbnailWidth, $this->thumbnailHeight); if ($image === $thumbnail) { $fileSource->copy($fileDestination); } else { $thumbnail->write($fileDestination); } } else { $fileSource->copy($fileDestination); } } // remove application/ from the path return substr($fileDestination->getPath(), 12); }