/** * Returns the JS file content * * @param ContainerInterface $container Dependency injection container * @param ServerRequestInterface $request Request object * @param ResponseInterface $response Response object * @param array $args Associative list of route parameters * @return ResponseInterface $response Modified response object with generated output */ public static function fileAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args) { $contents = ''; $files = array(); $aimeos = $container->get('aimeos'); $type = isset($args['type']) ? $args['type'] : 'js'; foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $files = array_merge($files, $jsb2->getFiles($type)); } } foreach ($files as $file) { if (($content = file_get_contents($file)) !== false) { $contents .= $content; } } $response->getBody()->write($contents); if ($type === 'js') { $response = $response->withHeader('Content-Type', 'application/javascript'); } elseif ($type === 'css') { $response = $response->withHeader('Content-Type', 'text/css'); } return $response; }
/** * Returns the CSS/JS file content * * @return string CSS/JS files content */ public function fileAction() { $contents = ''; $files = array(); $type = $this->request->getArgument('type'); foreach (Base::getAimeos()->getCustomPaths('admin/jqadm') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $files = array_merge($files, $jsb2->getFiles($type)); } } foreach ($files as $file) { if (($content = file_get_contents($file)) === false) { throw new \RuntimeException(sprintf('File "%1$s" not found', $jsbAbsPath)); } $contents .= $content; } if ($type === 'js') { $this->response->setHeader('Content-Type', 'application/javascript'); } elseif ($type === 'css') { $this->response->setHeader('Content-Type', 'text/css'); } return $contents; }
/** * Returns the JS file content * * @param $type File type, i.e. "css" or "js" * @return Response Response object */ public function fileAction($type) { $contents = ''; $files = array(); $aimeos = $this->get('aimeos')->get(); foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $files = array_merge($files, $jsb2->getFiles($type)); } } foreach ($files as $file) { if (($content = file_get_contents($file)) !== false) { $contents .= $content; } } $response = new Response($contents); if ($type === 'js') { $response->headers->set('Content-Type', 'application/javascript'); } elseif ($type === 'css') { $response->headers->set('Content-Type', 'text/css'); } return $response; }
/** * Returns the JS file content * * @return \Illuminate\Http\Response Response object containing the generated output */ public function fileAction() { if (config('shop.authorize', true)) { $this->authorize('admin', [['admin', 'editor']]); } $contents = ''; $files = array(); $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get(); $type = Route::input('type', Input::get('type', 'js')); foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $files = array_merge($files, $jsb2->getFiles($type)); } } foreach ($files as $file) { if (($content = file_get_contents($file)) !== false) { $contents .= $content; } } $response = response($contents); if ($type === 'js') { $response->header('Content-Type', 'application/javascript'); } elseif ($type === 'css') { $response->header('Content-Type', 'text/css'); } return $response; }
/** * Returns the JS file content * * @return Response Response object */ public function fileAction() { $contents = ''; $jsFiles = array(); $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get(); foreach ($aimeos->getCustomPaths('client/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $jsFiles = array_merge($jsFiles, $jsb2->getUrls('js', '')); } } foreach ($jsFiles as $file) { if (($content = file_get_contents($file)) !== false) { $contents .= $content; } } return response($contents)->header('Content-Type', 'application/javascript'); }
/** * Generates JS package files given in the manifests, including extensions. */ public function main() { $this->log('Generating JSB2 packages'); foreach ($this->aimeos->getCustomPaths('client/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbPath = $base . DIRECTORY_SEPARATOR . $path; $this->log(sprintf('Package: %1$s ', $jsbPath)); if (!is_file($jsbPath) || !is_readable($jsbPath)) { $this->log(sprintf('No manifest file found in %1$s', $jsbPath)); continue; } try { $jsbParser = new \Aimeos\MW\Jsb2\Standard($jsbPath); $jsbParser->deploy('js'); } catch (\Exception $e) { $this->log(sprintf('Error: %1$s', $e->getMessage())); } } } }
/** * Returns the JS file content * * @return Response Response object */ public function fileAction() { $contents = ''; $jsFiles = array(); foreach (Base::getAimeos()->getCustomPaths('client/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $jsFiles = array_merge($jsFiles, $jsb2->getUrls('js', '')); } } foreach ($jsFiles as $file) { if (($content = file_get_contents($file)) === false) { throw new \Exception(sprintf('File "%1$s" not found', $jsbAbsPath)); } $contents .= $content; } $response = $this->getControllerContext()->getResponse(); $response->setHeader('Content-Type', 'application/javascript'); $response->setContent($contents); return $response; }
/** * Returns the JS file content * * @return \TYPO3\Flow\Http\Response Response object */ public function fileAction() { $files = array(); $aimeos = $this->aimeos->get(); $type = $this->request->getArgument('type'); foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); $files = array_merge($files, $jsb2->getFiles($type)); } } foreach ($files as $file) { if (($content = file_get_contents($file)) !== false) { $this->response->appendContent($content); } } if ($type === 'js') { $this->response->setHeader('Content-Type', 'application/javascript'); } elseif ($type === 'css') { $this->response->setHeader('Content-Type', 'text/css'); } }
public function testGetUrlsFilemtimeException() { $object = new \Aimeos\MW\Jsb2\Standard($this->manifestPath . 'manifest_filemtime_exception.jsb2'); $this->setExpectedException('\\Aimeos\\MW\\Jsb2\\Exception'); $object->getHTML('js'); }