/** * Method to test stripExtension(). * * @return void * * @covers Windwalker\Filesystem\File::stripExtension */ public function testStripExtension() { $name = File::stripExtension('Wu-la.la'); $this->assertEquals('Wu-la', $name); $name = File::stripExtension(__DIR__ . '/Wu-la.la'); $this->assertEquals(__DIR__ . '/Wu-la', $name); }
/** * generateEntry * * @param Asset $entry * * @return Page */ public function generateEntry(Asset $entry) { $view = new PageHtmlView(); $layout = File::stripExtension($entry->getPath()); $html = $view->setLayout($layout)->render(); $file = $layout . '.html'; return new Page($file, $html); }
/** * findPaths * * @param string $layout * * @return \SplFileInfo */ public function findPaths($layout = null) { $layout = $layout ?: $this->getLayout(); if (is_file($this->getPath() . '/' . $layout)) { return new \SplFileInfo(realpath($this->getPath() . '/' . $layout)); } $layout = explode('/', $layout); $name = array_pop($layout); $layout = implode('/', $layout); if (is_dir($this->getPath() . '/' . $layout)) { $files = Filesystem::find($this->path . '/' . $layout, $name); /** @var \SplFileInfo $file */ foreach ($files as $file) { if (File::stripExtension($file->getFilename()) == $name) { return $file; } } } return null; }
/** * doExecute * * @return int */ protected function doExecute() { $path = $this->getArgument(0); $package = $this->getOption('p'); $folder = $this->console->get('asset.folder', 'asset'); if ($package = PackageHelper::getPackage($package)) { $path = $package->getDir() . '/Resources/asset/' . $path; } else { $path = WINDWALKER_PUBLIC . '/' . trim($folder, '/') . '/' . $path; } if (is_file($path)) { $files = array(new \SplFileInfo($path)); } elseif (is_dir($path)) { $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::FOLLOW_SYMLINKS)); } else { throw new \InvalidArgumentException('No path'); } /** @var \SplFileInfo $file */ foreach ($files as $file) { $ext = File::getExtension($file->getPathname()); if (StringHelper::endsWith($file->getBasename(), '.min.' . $ext)) { continue; } if ($ext == 'css') { $this->out('[<comment>Compressing</comment>] ' . $file); $data = \Minify_CSS_Compressor::process(file_get_contents($file)); $data = str_replace("\n", ' ', $data); } elseif ($ext == 'js') { $this->out('[<comment>Compressing</comment>] ' . $file); $data = \JSMinPlus::minify(file_get_contents($file)); $data = str_replace("\n", ';', $data); } else { continue; } $newName = $file->getPath() . '/' . File::stripExtension($file->getBasename()) . '.min.' . $ext; file_put_contents($newName, $data); $this->out('[<info>Compressed</info>] ' . $newName); } }
/** * loadAllFromPath * * @param string $path * @param string $format * @param string $package */ public static function loadAllFromPath($path, $format, $package = null) { $config = Ioc::getConfig(); $locale = $config['language.locale'] ?: 'en-GB'; $default = $config['language.default'] ?: 'en-GB'; $locale = LanguageNormalize::toLanguageTag($locale); $default = LanguageNormalize::toLanguageTag($default); $localePath = $path . '/' . $locale; $files = array(); if (is_dir($localePath)) { $files = array_merge($files, (array) Folder::files($localePath, false, Folder::PATH_BASENAME)); } $defaultPath = $path . '/' . $default; if (is_dir($defaultPath)) { $files = array_merge($files, (array) Folder::files($defaultPath, false, Folder::PATH_BASENAME)); } foreach ($files as $file) { $ext = File::getExtension($file); if (strcasecmp($ext, $format) !== 0) { continue; } Translator::loadFile(File::stripExtension($file), strtolower($format), $package); } }
/** * Method to get property Target * * @return string */ public function getTarget() { if (!$this->target) { $this->target = ltrim($this->getLayout(), '\\/'); $this->target = File::stripExtension($this->target) . '.html'; } return $this->target; }
/** * getRoute * * @return string */ public function getRoute() { if ($this->name == 'index' || $this->name == 'default') { $route = dirname($this->path); return Path::clean($route == '.' ? null : $route, '/'); } return Path::clean(File::stripExtension($this->path), '/'); }
/** * delete * * @param string $path * * @return boolean */ public function delete($path) { $path = File::stripExtension($path); $basic = $this->imgur->api('image')->deleteImage($path)->getData(); return $basic['success']; }
/** * getItem * * @param array $paths * * @return string */ public function getItem($paths) { $path = array_pop($paths); return \Windwalker\Filesystem\File::stripExtension($path); }