/** * Returns the initial HTML view for the admin interface. * * @param \Illuminate\Http\Request $request Laravel request object * @return \Illuminate\Contracts\View\View View for rendering the output */ public function indexAction(Request $request) { if (config('shop.authorize', true)) { $this->authorize('admin', [['admin']]); } $site = Route::input('site', Input::get('site', 'default')); $lang = Route::input('lang', Input::get('lang', config('app.locale', 'en'))); $tab = Route::input('tab', Input::get('tab', 0)); $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos'); $bootstrap = $aimeos->get(); $cntlPaths = $bootstrap->getCustomPaths('controller/extjs'); $context = app('\\Aimeos\\Shop\\Base\\Context')->get(false, 'backend'); $context->setLocale(app('\\Aimeos\\Shop\\Base\\Locale')->getBackend($context, $site)); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); $cssFiles = array(); foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); } } $jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product')); $jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token())); $adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>')); $vars = array('site' => $site, 'lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages($context), 'config' => $this->getJsonClientConfig($context), 'siteitem' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)), 'uploaddir' => config('shop::uploaddir'), 'version' => $aimeos->getVersion(), 'jqadmurl' => $jqadmUrl, 'activeTab' => $tab); return View::make('shop::extadm.index', $vars); }
/** * Returns the view for the ExtJS admin interface * * @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 indexAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args) { $site = isset($args['site']) ? $args['site'] : 'default'; $lang = isset($args['lang']) ? $args['lang'] : 'en'; $tab = isset($args['tab']) ? $args['tab'] : 0; $aimeos = $container->get('aimeos'); $cntlPaths = $aimeos->getCustomPaths('controller/extjs'); $context = $container->get('aimeos_context')->get(false, $args, 'backend'); $context = self::setLocale($context, $site, $lang); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); $cssFiles = array(); foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); } } $csrfname = $request->getAttribute('csrf_name'); $csrfvalue = $request->getAttribute('csrf_value'); $router = $container->get('router'); $jqadmUrl = $router->pathFor('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product')); $jsonUrl = $router->pathFor('aimeos_shop_extadm_json', array('site' => $site, $csrfname => $csrfvalue)); $adminUrl = $router->pathFor('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>')); $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => self::getJsonLanguages($aimeos), 'config' => self::getJsonClientConfig($context), 'site' => self::getJsonSiteItem($context, $site), 'i18nContent' => self::getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'uploaddir' => $context->getConfig()->get('uploaddir', '/.'), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => $adminUrl, 'jqadmurl' => $jqadmUrl, 'activeTab' => $tab, 'version' => \Aimeos\Slim\Bootstrap::getVersion()); return $container->get('view')->render($response, 'Extadm/index.html.twig', $vars); }
/** * Returns the initial HTML view for the admin interface. * * @param Request $request Symfony request object * @return Response Generated output for the admin interface */ public function indexAction(Request $request) { $site = $request->attributes->get('site', $request->query->get('site', 'default')); $lang = $request->attributes->get('lang', $request->query->get('lang', 'en')); $tab = $request->attributes->get('tab', $request->query->get('tab', 0)); $context = $this->get('aimeos_context')->get(false, 'backend'); $context->setLocale($this->get('aimeos_locale')->getBackend($context, $site)); $aimeos = $this->get('aimeos'); $bootstrap = $aimeos->get(); $cntlPaths = $bootstrap->getCustomPaths('controller/extjs'); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); $cssFiles = array(); foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); } } $params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}'); $adminUrl = $this->generateUrl('aimeos_shop_extadm', $params); $token = $this->get('security.csrf.token_manager')->getToken('aimeos_admin_token')->getValue(); $jsonUrl = $this->generateUrl('aimeos_shop_extadm_json', array('_token' => $token, 'site' => $site)); $jqadmUrl = $this->generateUrl('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product')); $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages(), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => urldecode($adminUrl), 'uploaddir' => $this->container->getParameter('aimeos_shop.uploaddir'), 'version' => $aimeos->getVersion(), 'jqadmurl' => $jqadmUrl, 'activeTab' => $tab); return $this->render('AimeosShopBundle:Extadm:index.html.twig', $vars); }
/** * Creates the initial HTML view for the admin interface. * * @param string $site Shop site code * @param string $lang ISO language code * @param integer $tab Number of the current active tab */ public function indexAction($site = 'default', $lang = 'en', $tab = 0) { $context = $this->context->get(null, 'backend'); $context->setLocale($this->locale->getBackend($context, $site)); $aimeos = $this->aimeos->get(); $cntlPaths = $aimeos->getCustomPaths('controller/extjs'); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); $cssFiles = array(); foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css', '')); } } $params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}'); $adminUrl = $this->uriBuilder->uriFor('index', $params); $jsonUrl = $this->uriBuilder->uriFor('do', array('site' => 'default')); $jqadmUrl = $this->uriBuilder->uriFor('search', array('site' => $site, 'resource' => 'product'), 'Jqadm'); $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages(), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'uploaddir' => $context->getConfig()->get('flow/uploaddir', '/.'), 'version' => $this->aimeos->getVersion(), 'urlTemplate' => urldecode($adminUrl), 'jqadmurl' => $jqadmUrl, 'activeTab' => $tab); $this->view->assignMultiple($vars); }
/** * 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'); }
/** * 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; }
/** * Generates the index file for the admin interface. */ public function indexAction() { $cssFiles = array(); $abslen = strlen(PATH_site); $controller = $this->getController(); $locale = $this->getContextBackend()->getLocale(); $site = $locale->getSite()->getCode(); $langid = 'en'; if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') { $langid = $GLOBALS['BE_USER']->uc['lang']; } foreach (Base::getAimeos()->getCustomPaths('admin/extjs') as $base => $paths) { $relJsbPath = '../' . substr($base, $abslen); foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \RuntimeException(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, ''); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); } } // rawurldecode() is necessary for ExtJS templates to replace "{site}" properly $urlTemplate = rawurldecode(BackendUtility::getModuleUrl($this->request->getPluginName(), array('tx_aimeos_web_aimeostxaimeosadmin' => array('controller' => 'Extadm', 'action' => 'index', 'site' => '{site}', 'tab' => '{tab}')))); $serviceUrl = BackendUtility::getModuleUrl($this->request->getPluginName(), array('tx_aimeos_web_aimeostxaimeosadmin' => array('controller' => 'Extadm', 'action' => 'do'))); $jqadmUrl = BackendUtility::getModuleUrl($this->request->getPluginName(), array('tx_aimeos_web_aimeostxaimeosadmin' => array('controller' => 'Jqadm', 'action' => 'search', 'site' => $site, 'resource' => 'product'))); $this->view->assign('cssFiles', $cssFiles); $this->view->assign('lang', $langid); $this->view->assign('i18nContent', $this->getJsonClientI18n($langid)); $this->view->assign('config', $this->getJsonClientConfig()); $this->view->assign('site', $this->getSite($this->request)); $this->view->assign('smd', $controller->getJsonSmd($serviceUrl)); $this->view->assign('itemSchemas', $controller->getJsonItemSchemas()); $this->view->assign('searchSchemas', $controller->getJsonSearchSchemas()); $this->view->assign('activeTab', $this->request->hasArgument('tab') ? (int) $this->request->getArgument('tab') : 0); $this->view->assign('version', Base::getVersion()); $this->view->assign('urlTemplate', $urlTemplate); $this->view->assign('jqadmurl', $jqadmUrl); }