Show the application dashboard.

@param  Request $request
@return array $pageblock
18862
public function update(Request $request)
    {
        // AUTHORIZE ... COMES HERE
        $pageblock = $this->pageblock->getById($request->get('pageblock_id'));
        $pageblock = $this->pageBlockRepository->updateBody($pageblock, $request->get('html'));
        return $pageblock;
    }
795974
public function updateLayoutBlockSortAction( Request $request ) {
		$zones  = $request->get( 'zones', [] );
		$pageId = $request->get( 'pageId' );
		$code = $request->get( 'code' );

		if ( ! $pageId ) {
			throw $this->createNotFoundException();
		}
		$pageAdmin = $this->container->get( $code );
		foreach ( $zones as $zone ) {
			$zoneName = $zone['zone'];
			if ( array_key_exists( 'layoutBlocks', $zone ) && is_array( $zone['layoutBlocks'] ) ) {
				foreach ( $zone['layoutBlocks'] as $key => $layoutBlockStr ) {
					$sort    = ++ $key;
					$blockId = str_replace( 'layoutBlock_', '', $layoutBlockStr );

					if ( $blockId ) {
						try {
							/** @var \Networking\InitCmsBundle\Model\LayoutBlockInterface $layoutBlock */
							$layoutBlock = $this->admin->getObject( $blockId );
							if ( $layoutBlock ) {
								$layoutBlock->setSortOrder( $sort );
								$layoutBlock->setZone( $zoneName );
							}

							$this->admin->update( $layoutBlock );
						} catch ( \Exception $e ) {
							$message = $e->getMessage();

							return new JsonResponse( [ 'messageStatus' => 'error', 'message' => $message ] );
						}
					}
				}
			}
		}


		$page = $pageAdmin->getModelManager()->find( $pageAdmin->getClass(), $pageId );
		$pageAdmin->setSubject( $page );

		$pageStatus = $this->renderView(
			'@NetworkingInitCms/PageAdmin/page_status_settings.html.twig',
			[ 'admin' => $pageAdmin, 'object' => $page ] );

		$data = [
			'pageStatusSettings' => $pageStatus,
			'pageStatus'         => $this->translate( $page->getStatus() ),
			'messageStatus'      => 'success',
			'message'            => $this->translate( 'message.layout_blocks_sorted', [ 'zone' => '' ] ),
		];

		return new JsonResponse( $data );
	}
415412
public function renderAction(Request $request)
    {
        /*
        $this->admin->checkAccess('compose');
        if (false === $this->get('sonata.dashboard.admin.block')->isGranted('LIST')) {
            throw $this->createAccessDeniedException();
        }
        */

        $admin = $this->getAdmin();

        $id = $request->get($admin->getIdParameter());

        $dashboard = $admin->getObject($id);

        if (!$dashboard) {
            throw $this->createNotFoundException(sprintf('unable to find the dashboard with id : %s', $id));
        }

        $containers = [];

        /** @var array $blocks */
        $blocks = $dashboard->getBlocks();

        // separate containers.
        foreach ($blocks as $block) {
            $containers[] = $block;
        }

        return $this->renderWithExtraParams('@CompoSonataDashboard/Dashboard/render.html.twig', [
            'action' => 'render',
            'admin' => $admin,
            'object' => $dashboard,

            'dashboard' => $dashboard,
            'containers' => $containers,
        ]);
    }
511191
public function select(Request $request)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

        // Get all pagetypes
        $pagetypes = PageType::all();
        return view('page::pages.select', ['pagetypes' => $pagetypes]);
    }
178912
public function composeAction(Request $request)
    {
        $admin = $this->getAdmin();

        $admin->checkAccess('compose');
        if (false === $this->get('sonata.dashboard.admin.block')->isGranted('LIST')) {
            throw $this->createAccessDeniedException();
        }

        $id = $request->get($admin->getIdParameter());
        $dashboard = $admin->getObject($id);
        if (!$dashboard) {
            throw $this->createNotFoundException(sprintf('unable to find the dashboard with id : %s', $id));
        }

        $containers = [];

        // separate containers.
        /** @var array $blocks */
        $blocks = $dashboard->getBlocks();

        foreach ($blocks as $block) {
            /** @var Block $block */
            $blockCode = $block->getSetting('code');
            if (null === $block->getParent()) {
                $containers[$blockCode]['block'] = $block;
            }
        }

        return $this->renderWithExtraParams($template = $admin->getTemplate('compose'), [
            'object' => $dashboard,
            'action' => 'edit',
            'containers' => $containers,
            'csrfTokens' => [
                'remove' => $this->getCsrfToken('sonata.delete'),
            ],
        ]);
    }
424139
public function index(Request $request)
    {
        $twoFactor = $request->user($this->getGuard())->getTwoFactor();

        return view('cortex/auth::managerarea.pages.account-twofactor', compact('twoFactor'));
    }
1104519
public function getPageBlocksByRequest(Request $request)
    {
        $routeName = $request->get('_route');
        $pageName = $this->routeConfig->getPageName($routeName);

        if (!isset($this->pageBlocks[$pageName])) {
            throw new \Exception(
                sprintf(
                    'Not found blocs for page with name \'%s\' and route name \'%s\'',
                    $pageName,
                    $routeName
                )
            );
        }
        $blocks = $this->pageBlocks[$pageName];

        // add route_params to blocks
        foreach ($blocks as $index => $block) {
            $blocks[$index]['settings']['route_params'] = $request->get('_route_params');
        }

        return $blocks;
    }
342041
public function indexAction(Request $request)
    {
        $this->init($request);

        $nodeAdminListConfigurator = new NodeAdminListConfigurator(
            $this->em,
            $this->aclHelper,
            $this->locale,
            PermissionMap::PERMISSION_VIEW,
            $this->authorizationChecker
        );

        $locale = $this->locale;
        $acl = $this->authorizationChecker;
        $itemRoute = function (EntityInterface $item) use ($locale, $acl) {
            if ($acl->isGranted(PermissionMap::PERMISSION_VIEW, $item->getNode())) {
                return array(
                    'path' => '_slug_preview',
                    'params' => ['_locale' => $locale, 'url' => $item->getUrl()],
                );
            }
        };
        $nodeAdminListConfigurator->addSimpleItemAction('action.preview', $itemRoute, 'eye');
        $nodeAdminListConfigurator->setDomainConfiguration($this->get('kunstmaan_admin.domain_configuration'));
        $nodeAdminListConfigurator->setShowAddHomepage($this->getParameter('kunstmaan_node.show_add_homepage') && $this->isGranted('ROLE_SUPER_ADMIN'));

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

        return array(
            'adminlist' => $adminlist,
        );
    }
663126
public function displayTermsOfUse(Request $request)
    {
        $toDisplay = $request->query->get('to_display', []);
        $data = [];

        foreach ($this->getApplicationBox()->get_databoxes() as $databox) {
            if (count($toDisplay) > 0 && !in_array($databox->get_sbas_id(), $toDisplay)) {
                continue;
            }

            $cgus = $databox->get_cgus();

            if (!isset($cgus[$this->app['locale']])) {
                continue;
            }

            $data[$databox->get_label($this->app['locale'])] = $cgus[$this->app['locale']]['value'];
        }

        return $this->renderResponse('/prod/TOU.html.twig', [
            'TOUs'        => $data,
            'local_title' => $this->app->trans('Terms of use'),
        ]);
    }
961387
public function index(Request $request)
    {
        $permissions = Permission::browse([
            'order'     => [ Input::get('sort', 'id') => Input::get('direction', 'desc') ],
            'limit'     => ($limit = (int)Input::get('limit', 25)),
            'offset'    => (Input::get('page', 1) - 1) * $limit,
            'filters'   => $request->all()
        ]);

        return response()->json(arrayView('phpsoft.users::permission/browse', [
            'permissions' => $permissions,
        ]), 200);
    }
119540
public function composePreviewAction(Request $request = null)
    {
        $this->admin->checkAccess('composePreview');

        $blockId = $request->get('block_id');

        /** @var BaseBlock $block */
        $block = $this->admin->getObject($blockId);
        if (!$block) {
            throw new PageNotFoundException(sprintf('Unable to find block with id %d', $blockId));
        }

        $container = $block->getParent();
        if (!$container) {
            throw new PageNotFoundException('No parent found, unable to preview an orphan block');
        }

        $blockServices = $this->get('sonata.block.manager')->getServicesByContext('sonata_page_bundle', false);

        return $this->render('@SonataPage/BlockAdmin/compose_preview.html.twig', [
            'container' => $container,
            'child' => $block,
            'blockServices' => $blockServices,
        ]);
    }
1263010
public function index(Request $request)
    {
        $keyword = $request->get('search');
        $perPage = 25;

        if (!empty($keyword)) {
            $pages = Page::where('title', 'LIKE', "%$keyword%")
                ->orWhere('content', 'LIKE', "%$keyword%")
                ->latest()->paginate($perPage);
        } else {
            $pages = Page::latest()->paginate($perPage);
        }

        return view('admin.pages.index', compact('pages'));
    }
922482
public function layoutAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateBlockLayout($block, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($block);
        $this->persist($block);

        $data = [
            'blocks' => [$this->getViewBuilder()->buildBlock($block)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
407793
public function pagesListAction(Request $request)
    {
        $repository = $this->get('ekyna_cms.page.repository');

        $lastModifiedAt = $repository->getLastUpdatedAt();

        $response = new Response();
        $response->headers->set('Content-Type', 'application/json');
        $response->setLastModified($lastModifiedAt);

        if ($response->isNotModified($request)) {
            return $response;
        }

        $documentLocale = $request->query->get('document_locale', $request->getLocale());
        $list = [];

        /** @var \Ekyna\Bundle\CmsBundle\Model\PageInterface[] $pages */
        $pages = $this
            ->get('ekyna_cms.page.repository')
            ->findBy(['dynamicPath' => false], ['left' => 'ASC']);

        foreach ($pages as $page) {
            $list[] = $this->pageToArray($page, $documentLocale);
        }

        return $response->setContent(json_encode($list));
    }
252189
public function showAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        /* @var $rep NoticeRepository */
        $rep = $em->getRepository('AnimeDbAppBundle:Notice');

        $notice = $rep->getFirstShow();
        // caching
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
        $response->setEtag(md5($notice ? $notice->getId() : 0));
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        // shown notice
        if (!is_null($notice)) {
            $notice->shown();
            $em->persist($notice);
            $em->flush();

            $response->setData([
                'notice' => $notice->getId(),
                'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
                'see_later' => $this->generateUrl('notice_see_later'),
                'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
                    'notice' => $notice,
                    'link_all' => $request->query->getBoolean('all'),
                ]),
            ]);
        }

        return $response;
    }
833655
public function treeAction(Request $request = null)
    {
        $this->admin->checkAccess('tree');

        $sites = $this->get('sonata.page.manager.site')->findBy(array());
        $pageManager = $this->get('sonata.page.manager.page');

        $currentSite = null;
        $siteId = $request->get('site');
        foreach ($sites as $site) {
            if ($siteId && $site->getId() === $siteId) {
                $currentSite = $site;
            } elseif (!$siteId && $site->getIsDefault()) {
                $currentSite = $site;
            }
        }
        if (!$currentSite && count($sites) === 1) {
            $currentSite = $sites[0];
        }

        $showAllPages = $this->get('security.context')->isGranted('ROLE_SUPER_ADMIN');

        if ($currentSite) {
            $pages = $pageManager->loadPages($currentSite, $showAllPages);
        } else {
            $pages = array();
        }

        $datagrid = $this->admin->getDatagrid();
        $formView = $datagrid->getForm()->createView();

        $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());

        return $this->render($this->admin->getTemplate('tree'), array(
            'action' => 'tree',
            'sites' => $sites,
            'currentSite' => $currentSite,
            'pages' => $pages,
            'form' => $formView,
            'csrf_token' => $this->getCsrfToken('sonata.batch'),
        ));
    }
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
        ]);
    }