Get Databases control panel

@param Request $request
@return Response
508944
public function getDatabases(Request $request)
    {
        $acl = $this->getAclForUser();
        $sbasIds = array_merge(
            array_keys($acl->get_granted_sbas([\ACL::BAS_MANAGE])),
            array_keys($acl->get_granted_sbas([\ACL::BAS_MODIFY_STRUCT]))
        );

        $sbas = [];
        foreach ($sbasIds as $sbasId) {
            $sbas[$sbasId] = [
                'version'     => 'unknown',
                'image'       => '/assets/common/images/icons/db-remove.png',
                'server_info' => '',
                'name'        => $this->app->trans('Unreachable server')
            ];

            try {
                $databox = $this->findDataboxById($sbasId);

                /** @var \PDO $pdoConnection */
                $pdoConnection = $databox->get_connection()->getWrappedConnection();
                $sbas[$sbasId] = [
                    'version'     => $databox->get_version(),
                    'image'       => '/assets/common/images/icons/foldph20close_0.gif',
                    'server_info' => $pdoConnection->getAttribute(\PDO::ATTR_SERVER_VERSION),
                    'name'        => \phrasea::sbas_labels($sbasId, $this->app)
                ];
            } catch (\Exception $e) {

            }
        }

        switch ($errorMsg = $request->query->get('error')) {
            case 'scheduler-started' :
                $errorMsg = $this->app->trans('Veuillez arreter le planificateur avant la mise a jour');
                break;
            case 'already-started' :
                $errorMsg = $this->app->trans('The upgrade is already started');
                break;
            case 'unknow' :
                $errorMsg = $this->app->trans('An error occured');
                break;
            case 'bad-email' :
                $errorMsg = $this->app->trans('Please fix the database before starting');
                break;
            case 'special-chars' :
                $errorMsg = $this->app->trans('Database name can not contains special characters');
                break;
            case 'base-failed' :
                $errorMsg = $this->app->trans('Base could not be created');
                break;
            case 'database-failed' :
                $errorMsg = $this->app->trans('Database does not exists or can not be accessed');
                break;
            case 'no-empty' :
                $errorMsg = $this->app->trans('Database can not be empty');
                break;
            case 'mount-failed' :
                $errorMsg = $this->app->trans('Database could not be mounted');
                break;
            case 'innodb-support' :
                $errorMsg = $this->app->trans('Database server does not support InnoDB storage engine');
                break;
        }

        return $this->render('admin/databases.html.twig', [
            'files'      => new \DirectoryIterator($this->app['root.path'] . '/lib/conf.d/data_templates'),
            'sbas'       => $sbas,
            'error_msg'  => $errorMsg,
            'advices'    => $request->query->get('advices', []),
            'reloadTree' => (Boolean) $request->query->get('reload-tree'),
        ]);
    }
812771
public function getPage(Request $request)
    {
        $parameters = $this->fixParameters($request->query->all());

        $transUnits = $this->storage->getTransUnitList(
            $this->localeManager->getLocales(),
            $request->query->get('rows', 20),
            $request->query->get('page', 1),
            $parameters
        );

        $count = $this->storage->countTransUnits($this->localeManager->getLocales(), $parameters);

        return array($transUnits, $count);
    }
418421
public function indexAction(Request $request)
    {
        $configurator = $this->getAdminListConfigurator();

        /* @var AdminList $adminList */
        $adminList = $this->container->get('kunstmaan_adminlist.factory')->createList($configurator);
        $adminList->bindRequest($request);

        $cacheFresh = $this->container->get('kunstmaan_translator.service.translator.cache_validator')->isCacheFresh();
        $debugMode = $this->container->getParameter('kuma_translator.debug') === true;

        if (!$cacheFresh && !$debugMode) {
            $this->addFlash(
                FlashTypes::INFO,
                $this->container->get('translator')->trans('settings.translator.not_live_warning')
            );
        }

        return [
            'adminlist' => $adminList,
            'adminlistconfigurator' => $configurator,
        ];
    }
860874
public function indexAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Item');
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // current page for paging
        $page = $request->get('page', 1);
        $current_page = $page > 1 ? $page : 1;

        /* @var $rep ItemRepository */
        $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item');
        /* @var $controls ListControls */
        $controls = $this->get('anime_db.item.list_controls');

        $pagination = null;
        // show not all items
        if ($limit = $controls->getLimit($request->query->all())) {
            $that = $this;
            $query = $request->query->all();
            unset($query['page']);
            $pagination = $this->get('anime_db.pagination')
                ->create(ceil($rep->count() / $limit), $current_page)
                ->setPageLink(function ($page) use ($that, $query) {
                    return $that->generateUrl('home', array_merge($query, ['page' => $page]));
                })
                ->setFirstPageLink($this->generateUrl('home', $query))
                ->getView();
        }

        // get items
        $items = $rep->getList($limit, ($current_page - 1) * $limit);

        return $this->render('AnimeDbCatalogBundle:Home:index.html.twig', [
            'items' => $items,
            'pagination' => $pagination,
            'widget_top' => self::WIDGET_PALCE_TOP,
            'widget_bottom' => self::WIDGET_PALCE_BOTTOM,
        ], $response);
    }
815265
private function indexAjax(Request $request)
    {
        // GET THE SLUG, ex. 'posts', 'pages', etc.
        $slug = $this->getSlug($request);

        // GET THE DataType based on the slug
        $dataType = Admin::model('DataType')->where('slug', '=', $slug)->first();

        // Check permission
        $this->authorize('browse', app($dataType->model_name));

        $isServerSide = false;
        $isModelTranslatable = false;
        $columns = $dataType->fields();
        $pagination = $dataType->pagination;

        $view='admin::crud.browse-ajax';

        if (view()->exists("admin::$slug.browse-ajax")) {
            $view = "admin::$slug.browse-ajax";
        }

        return Admin::view($view, compact(
            'dataType',
            'slug',
            'isServerSide',
            'isModelTranslatable',
            'columns',
            'pagination'
        ));
    }
960053
public function role(Request $request)
    {
        if($request->get('_ajax')) {
            $ename = $request->input('ename');
            $parent = $request->input('parent');
            $uri = $request->input('uri');
            $query = CommonRoleUriModel::where('id', '>', 0);
            if($ename) {
                $query->where('ename', $ename);
            }
            if($uri) {
                $query->where('uri', $uri);
            }
            if($parent) {
                $query->where('parent', $parent);
            }
            $list = $query->orderby('id', 'desc')->paginate($this->paginate);
            $this->addMessage($list, 'list');
            return $this->showMessage('Hstcms::public.successful');
        }
        $view = [
            'navs'=>$this->getNavs('operation')
        ];
        $this->navs = [
            'nav'=>['name'=>hst_lang('hstcms::public.menu'), 'url'=>'manageMenuNav'],
            'role'=>['name'=>hst_lang('hstcms::manage.role.uri'), 'url'=>'manageMenuRole'],
            'add'=>['name'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri'), 'url'=>'manageMenuRoleAdd', 'class'=>'J_dialogs', 'title'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri')]
        ];
        $view = [
            'navs'=>$this->getNavs('role')
        ];
        return $this->loadTemplate('menu.role', $view);
    }
269493
public function index(Request $request)
    {
        $isTrash = $request->is('users/trash');

        $users = AppUser::browse([
            'order'     => [ Input::get('sort', 'id') => Input::get('direction', 'desc') ],
            'limit'     => ($limit = (int)Input::get('limit', 25)),
            'cursor'    => Input::get('cursor'),
            'offset'    => (Input::get('page', 1) - 1) * $limit,
            'filters'   => $request->all(),
            'trash'     => $isTrash
        ]);

        return response()->json(arrayView('phpsoft.users::user/browse', [
            'users' => $users,
        ]), 200);
    }
916731
public function getPermissionsAction(Request $request)
    {
        $data = [];
        $group = $request->attributes->get('group');
        $aclManager = $this->getContainer()->get('security.acl_manager');

        foreach ($this->getApplication()->getBundles() as $bundle) {

            if ($bundle->isEnabled() && true === array_key_exists('admin_entry_point', $bundle->getProperty())) {

                $data[] = [
                    'uid' => $bundle->getId(),
                    'label' => $bundle->getProperty()['name'],
                    'class' => $bundle->getType(),
                    'rights' => $aclManager->getPermissions($bundle->getType(), $group)
                ];
            }
        }

        return $this->createJsonResponse($data, 200);
    }
907767
private function getSiteAccessFromRequest(Request $request)
    {
        return $this->siteAccessRouter->match(
            new SimplifiedRequest(
                array(
                    'scheme' => $request->getScheme(),
                    'host' => $request->getHost(),
                    'port' => $request->getPort(),
                    'pathinfo' => $request->getPathInfo(),
                    'queryParams' => $request->query->all(),
                    'languages' => $request->getLanguages(),
                    'headers' => $request->headers->all(),
                )
            )
        );
    }
4836
public function resolve(Request $request)
    {
        $request->databaseQueries = array_merge($request->databaseQueries, $this->getDatabaseQueries());

        return $request;
    }
278458
public function Information($Request) {
      if (array_key_exists($Request, $this->_DatabaseInfo) === FALSE) {
         if ($Request == 'Version') {
            $this->_DatabaseInfo['Version'] = $this->Version();
         } else {
            $this->_DatabaseInfo['HostName'] = Gdn::Config('Database.Host', '');
            $this->_DatabaseInfo['DatabaseName'] = Gdn::Config('Database.Name', '');
         }
      }
      if (array_key_exists($Request, $this->_DatabaseInfo) === TRUE) {
         return $this->_DatabaseInfo[$Request];
      } else {
         return '';
      }
   }
895032
public function adminAction(Request $request, $context)
    {
        // grab tabs data
        $tabs = $this->decodeRequest($request);

        $ids = [];
        $containerIds = [];
        $instanceIds = [];
        $updated = [];

        foreach ($tabs as $tab) {
            $updated[] = $this->crud->update(HomeTab::class, $tab, [$context]);
            $ids[] = $tab['id']; // will be used to determine deleted tabs

            foreach ($tab['widgets'] as $container) {
                $containerIds[] = $container['id'];
                foreach ($container['contents'] as $instance) {
                    $instanceIds[] = $instance['id'];
                }
            }
        }

        // retrieve existing tabs for the context to remove deleted ones
        /** @var HomeTab[] $installedTabs */
        $installedTabs = $this->finder->fetch(HomeTab::class, ['type' => HomeTab::TYPE_ADMIN_DESKTOP]);

        $this->cleanDatabase($installedTabs, $instanceIds, $containerIds, $ids);

        return new JsonResponse(array_values(array_map(function (HomeTab $tab) {
            return $this->serializer->serialize($tab);
        }, $updated)));
    }
1243870
private function getFilter(Request $request)
    {
        $success = false;
        $filter = null;
        if ($request->query->has('filter')) {
            $filter = $request->query->get('filter');
            $type = 'query';
        } elseif ($request->request->has('filter')) {
            $filter = $request->request->get('filter');
            $type = 'request';
        } elseif ($request->getMethod() === 'PUT') {
            $_PUT = json_decode($request->getContent(), true);
            if (!empty($_PUT['filter'])) {
                $filter = $_PUT['filter'];
                $type = 'put';
            }
        }

        if ($filter === null) {
            if ($this->container->getParameter('kernel.environment') === 'dev') {
                $value = new Response($this->get('translator')->trans('error.requestMustHasFilter', array(), 'ApoutchikaMediaBundle'), 500);
            } else {
                $value = new Response($this->get('translator')->trans('error.requestMustHasFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
            }
        } elseif (!$this->get('apoutchika_media.filter')->has($filter)) {
            if ($this->container->getParameter('kernel.environment') === 'dev') {
                $value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilter', array(), 'ApoutchikaMediaBundle'), 500);
            } else {
                $value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
            }
        } else {
            $success = true;
            $value = $this->get('apoutchika_media.filter')->get($filter);
        }

        return array(
            'success' => $success,
            'value' => $value,
            'crypted' => $filter,
        );
    }
523839
public function cgetAction(Request $request)
    {
        $checkForPermissions = $request->get('checkForPermissions', true);
        $locale = $this->getRequestParameter($request, 'locale', true);
        $webspaces = [];

        $securityChecker = $this->get('sulu_security.security_checker');
        foreach ($this->get('sulu_core.webspace.webspace_manager')->getWebspaceCollection() as $webspace) {
            if ($checkForPermissions) {
                $securityContext = $this->getSecurityContextByWebspace($webspace->getKey());
                if (!$securityChecker->hasPermission(new SecurityCondition($securityContext), PermissionTypes::VIEW)) {
                    continue;
                }
            }

            $webspaces[] = $webspace;
        }

        $context = new Context();
        $context->setAttribute('locale', $locale);
        $view = $this->view(new CollectionRepresentation($webspaces, 'webspaces'));
        $view->setContext($context);

        return $this->handleView($view);
    }
1203574
public function getDashboard(Request $request)
    {
        if ('json' === $request->getRequestFormat()) {
            \Session_Logger::updateClientInfos($this->app, 4);

            $dashboard = new \module_report_dashboard($this->app, $this->getAuthenticatedUser());

            $dmin = $request->query->get('dmin');
            $dmax = $request->query->get('dmax');

            if ($dmin && $dmax) {
                $dashboard->setDate($dmin, $dmax);
            }

            $dashboard->execute();

            return $this->app->json(['html' => $this->render('report/ajax_dashboard_content_child.html.twig', [
                'dashboard' => $dashboard
            ])]);
        }

        $granted = [];

        $acl = $this->getAclForUser();
        foreach ($acl->get_granted_base([\ACL::CANREPORT]) as $collection) {
            $sbas_id = $collection->get_sbas_id();
            if (!isset($granted[$sbas_id])) {
                $granted[$sbas_id] = [
                    'id'          => $sbas_id,
                    'name'        => $collection->get_databox()->get_viewname(),
                    'collections' => [],
                    'metas'       => []
                ];

                foreach ($collection->get_databox()->get_meta_structure() as $meta) {
                    // skip the fields that can't be reported
                    if (!$meta->is_report() || ($meta->isBusiness() && !$acl->can_see_business_fields($collection->get_databox()))) {
                        continue;
                    }
                    $granted[$sbas_id]['metas'][] = $meta->get_name();
                }
            }
            $granted[$sbas_id]['collections'][] = [
                'id'      => $collection->get_coll_id(),
                'base_id' => $collection->get_base_id(),
                'name'    => $collection->get_name(),
            ];
        }

        $conf = $this->getConf();

        return $this->render('report/report_layout_child.html.twig', [
            'ajax_dash'     => true,
            'dashboard'     => null,
            'granted_bases' => $granted,
            'home_title'    => $conf->get(['registry', 'general', 'title']),
            'module'        => 'report',
            'module_name'   => 'Report',
            'anonymous'     => $conf->get(['registry', 'modules', 'anonymous-report']),
            'g_anal'        => $conf->get(['registry', 'general', 'analytics']),
            'ajax'          => false,
            'ajax_chart'    => false
        ]);
    }
34520
public function directoryAction(Request $request)
    {
        $id = $request->query->get('id');

        $parent = null;
        if (intval($id)) {
            $em = $this->getDoctrine()->getManager();

            $parent = $em->getReference('ClasticMediaBundle:Directory', $id);
        }

        $directories = $this->getDoctrine()->getRepository('ClasticMediaBundle:Directory')
            ->findBy(array(
                'parent' => $parent,
            ));

        $data = array_map(function (Directory $directory) use ($parent) {
            return array(
                'id' => $directory->getId(),
                'text' => $directory->getName(),
                'children' => true,
                'state' => array(
                    'disabled' => false,
                    'opened' => !$parent,
                    'selected' => !$parent,
                ),
            );
        }, $directories);

        return new JsonResponse($data);
    }
706340
public function getCollection(Request $request)
    {
        /** @var \SymfonyId\AdminBundle\Configuration\ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);

        $reflectionModel = new \ReflectionClass($crudConfigurator->getCrud()->getModelClass());
        /** @var \SymfonyId\AdminBundle\Annotation\Driver $driver */
        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($reflectionModel->getName());
        /** @var \SymfonyId\AdminBundle\Crud\CrudOperationHandler $crudOperationHandler */
        $crudOperationHandler = $this->get('symfonyid.admin.crud.crud_operation_handler');

        $requestParam = new RequestParameter($request);

        /*
         * Convert from KnpPaginator to Pagerfanta.
         */
        /** @var \Knp\Component\Pager\Pagination\AbstractPagination $knpPaginator */
        $knpPaginator = $crudOperationHandler->paginateResult($driver, $reflectionModel->getName(), $requestParam->getPage(), $requestParam->getLimit());
        $pagerAdapter = new ArrayAdapter($knpPaginator->getItems());

        $pager = new Pagerfanta($pagerAdapter);
        $pager->setCurrentPage($requestParam->getPage());
        $pager->setMaxPerPage($requestParam->getLimit());

        $embed = strtolower($reflectionModel->getShortName().'s');
        $pagerFactory = new PagerfantaFactory();
        $representation = $pagerFactory->createRepresentation(
            $pager,
            new Route($request->get('_route'), $requestParam->toArray()),
            new CollectionRepresentation($pager->getCurrentPageResults(), $embed, $embed)
        );

        return $this->createResponse($representation);
    }