@Route("/", name="KunstmaanNodeBundle_nodes")
@Template("KunstmaanNodeBundle:Admin:list.html.twig")

@param Request $request

@return array
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,
        );
    }
755969
private function getParametersFromRequest(Request $request)
    {
        $parameters = $request->query->all();
        if ($routeParameters = $request->attributes->get('_route_params')) {
            $parameters = array_merge($routeParameters, $parameters);
        }

        return $parameters;
    }
999527
public function treeAction(Request $request)
    {
        $siterootId = $request->get('siteroot_id');
        $tid = $request->get('node');
        $language = $request->get('language');

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $elementService = $this->get('phlexible_element.element_service');
        $nodeSerializer = $this->get('phlexible_tree.node_serializer');

        // TODO: switch to master language of element
        $defaultLanguage = $this->container->getParameter('phlexible_cms.languages.default');

        $tree = $treeManager->getBySiteRootId($siterootId);
        $rootNode = $tree->getRoot();

        $data = [];
        if ($rootNode) {
            if ($tid === null || $tid < 1) {
                $data = [$nodeSerializer->serializeNode($rootNode, $language, $this->container->get('security.token_storage')->getToken())];
            } else {
                $node = $tree->get($tid);

                // check if children of this node should be shown
                $element = $elementService->findElement($node->getTypeId());
                $elementtype = $elementService->findElementtype($element);

                $nodes = $tree->getChildren($node);
                if (!empty($nodes) && !$elementtype->getHideChildren()) {
                    $data = $nodeSerializer->serializeNodes($nodes, $language, $this->container->get('security.token_storage')->getToken());
                }
            }
        }

        return new JsonResponse($data);
    }
436617
public function nodesFormAction(Request $request)
    {
        $node = new Node();
        // Manage edition mode
        $this->currentNode = $request->get('node');
        if ($this->currentNode) {
            $node = $this->get("ydle.node.manager")->find($request->get('node'));
        }
        $action = $this->get('router')->generate('submitNodeForm', array('node' => $this->currentNode));

        $form = $this->createForm("node_form", $node);
        $form->handleRequest($request);

        return $this->render('YdleHubBundle:Nodes:form.html.twig', array(
            'action' => $action,
            'entry' => $node,
            'form' => $form->createView()
        ));
    }
1321919
public function manyToManyForm(Request $request)
    {
        $dummyData = DatabaseManager::tableNames();
        $elements = Ajaxis::MtcreateFormModal([
            ['type' => 'select', 'name' => 'table1', 'key' => 'table1', 'value' => $dummyData],
            ['type' => 'select', 'name' => 'table2', 'key' => 'table2', 'value' => $dummyData], ], '/scaffold/manyToMany', 'Many To Many');

        return $elements;
    }
827324
public function listAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $root = $this->getFolderRepository()->findRoot();
        if (null !== $id = $request->query->get('folderId')) {
            if (!$this->activateFolderById($id, $root)) {
                $root->setActive(true);
            }
        } else {
            $root->setActive(true);
        }

        $folders = $this->get('jms_serializer')->serialize(
            array($root),
            'json',
            SerializationContext::create()->setGroups(array('Manager'))
        );

        $response = new Response($folders);
        $response->headers->add(array('Content-Type' => 'application/json'));

        return $response;
    }
1109058
public function listAction(Request $request)
    {
        $this->buildBreadcrumbs($this->getType());

        $file = new File();
        $form = $this->createForm(FileFormType::class, $file);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            $em->persist($file);
            $em->flush();

            return $this->redirect($this->generateUrl('clastic_node_list', array(
                'type' => $this->getType(),
            )));
        }

        return $this->render('ClasticMediaBundle:Backoffice:list.html.twig', array(
            'form' => $form->createView(),
            'type' => $this->getType(),
            'module' => $this->get('clastic.module_manager')->getModule($this->getType()),
        ));
    }
666576
public function cgetAction(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $fieldDescriptors = $this->getFieldDescriptors($locale, false);
        $types = array_filter(explode(',', $request->get('types')));
        $listBuilder = $this->getListBuilder($request, $fieldDescriptors, $types);
        $listBuilder->setParameter('locale', $locale);
        $listResponse = $listBuilder->execute();
        $count = $listBuilder->count();

        for ($i = 0, $length = count($listResponse); $i < $length; ++$i) {
            $format = $this->getFormatManager()->getFormats(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['storageOptions'],
                $listResponse[$i]['version'],
                $listResponse[$i]['subVersion'],
                $listResponse[$i]['mimeType']
            );

            if (0 < count($format)) {
                $listResponse[$i]['thumbnails'] = $format;
            }

            $listResponse[$i]['url'] = $this->getMediaManager()->getUrl(
                $listResponse[$i]['id'],
                $listResponse[$i]['name'],
                $listResponse[$i]['version']
            );
        }

        $ids = $listBuilder->getIds();
        if (null != $ids) {
            $result = [];
            foreach ($listResponse as $item) {
                $result[array_search($item['id'], $ids)] = $item;
            }
            ksort($result);
            $listResponse = array_values($result);
        }

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'cget_media',
            $request->query->all(),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $count
        );

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
1136202
protected function getData(Request $request)
    {
        return [
            'style' => $request->get('style'),
            'type' => $request->get('type', $this->container->getParameter('sulu_media.collection.type.default')),
            'parent' => $request->get('parent'),
            'locale' => $this->getRequestParameter($request, 'locale', true),
            'title' => $request->get('title'),
            'description' => $request->get('description'),
            'changer' => $request->get('changer'),
            'creator' => $request->get('creator'),
            'changed' => $request->get('changed'),
            'created' => $request->get('created'),
        ];
    }
1331275
public function listAction(Request $request)
    {
        $treeId = $request->get('tid');
        $layoutAreaId = $request->get('area_id');
        $language = $request->get('language');
        $sort = $request->get('sort', 'sort');
        $dir = $request->get('dir', 'ASC');

        $treeManager = $this->get('phlexible_tree.tree_manager');
        $teaserManager = $this->get('phlexible_teaser.teaser_manager');
        $elementService = $this->get('phlexible_element.element_service');
        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $iconResolver = $this->get('phlexible_element.icon_resolver');

        $treeNode = $treeManager->getByNodeId($treeId)->get($treeId);
        $treeNodePath = $treeNode->getTree()->getPath($treeNode);

        if (!$language) {
            $element = $elementService->findElement($treeNode->getTypeId());
            $language = $elementMasterLanguage = $element->getMasterLanguage();
        }

        $filter = $request->get('filter');
        if ($filter) {
            $filter = json_decode($filter, true);
        }

        $layoutarea = $elementtypeService->findElementtype($layoutAreaId);
        $teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);

        $parent = [
            'teaser_id' => $treeId, //(int) $teaserData->id,
            'tid' => 0,
            'title' => $treeNode->getId(), //$teaserData->text,
            'element_type_id' => (int) $layoutarea->getId(),
            'element_type' => $layoutarea->getTitle(),
            'icon' => $iconResolver->resolveElementtype($layoutarea),
            'author' => 'author',
            'version' => $layoutarea->getRevision(),
            'create_time' => $layoutarea->getCreatedAt(),
            //            'change_time'     => '2007-01-01 01:01:01',
            'publish_time' => null,
            'language' => $language,
            'sort' => 0,
            'sort_mode' => 'free',
            'sort_dir' => 'asc',
            'version_latest' => (int) $layoutarea->getRevision(),
            'version_online' => (int) $layoutarea->getRevision(),
            'status' => ' o_O ',
            'qtip' => $layoutarea->getTitle().', Version '.$layoutarea->getRevision().'<br>'.
                37 .' Versions<br>',
        ];

        $data = [];

        foreach ($teasers as $teaser) {
            /* @var $teaser Teaser */

            if ('element' === $teaser->getType()) {
                $teaserElement = $elementService->findElement($teaser->getTypeId());
                $teaserElementtype = $elementService->findElementtype($teaserElement);
                $teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);

                if (!empty($filter['status'])) {
                    $status = explode(',', $filter['status']);

                    $show = false;
                    if (in_array('online', $status) && $teaserManager->isPublished($teaser, $language) && !$teaserManager->isAsync($teaser, $language)) {
                        $show = true;
                    } elseif (in_array('async', $status) && $teaserManager->isAsync($teaserElement, $language)) {
                        $show = true;
                    } elseif (in_array('offline', $status) && !$teaserManager->isPublished($teaserElement, $language)) {
                        $show = true;
                    }

                    if (!$show) {
                        continue;
                    }
                }

                $teaserOnline = $teaserManager->findOneOnlineByTeaserAndLanguage($teaser, $language);

                if (!empty($filter['date'])) {
                    $date = $filter['date'];
                    $dateFrom = !empty($filter['date_from']) ? strtotime($filter['date_from']) : '';
                    $dateTo = !empty($filter['date_to']) ? strtotime($filter['date_to']) : '';

                    $show = false;
                    if ($date === 'create') {
                        $createdAt = $teaserElementVersion->getCreatedAt();

                        if ((!$dateFrom || $createdAt > $dateFrom) && (!$dateTo || $createdAt < $dateTo)) {
                            $show = true;
                        }
                    } elseif ($date === 'publish') {
                        $publishedAt = null;
                        if ($teaserOnline) {
                            $publishedAt = $teaserOnline->getPublishedAt();
                        }

                        if ((!$dateFrom || $publishedAt > $dateFrom) && (!$dateTo || $publishedAt < $dateTo)) {
                            $show = true;
                        }
                    } elseif ($date === 'custom') {
                        $customDate = $teaserElementVersion->getCustomDate($language);

                        if ((!$dateFrom || $customDate > $dateFrom) && (!$dateTo || $customDate < $dateTo)) {
                            $show = true;
                        }
                    }

                    if (!$show) {
                        continue;
                    }
                }

                $data[] = [
                    'teaser_id' => $teaser->getId(),
                    '_type' => $teaser->getType(),
                    'eid' => $teaser->getTypeId(),
                    'title' => $teaserElementVersion->getBackendTitle($language),
                    'element_type_id' => (int) $teaserElement->getElementtypeId(),
                    'element_type' => $teaserElementtype->getTitle(),
                    'navigation' => 0,
                    'restricted' => 0,
                    'icon' => $iconResolver->resolveTeaser($teaser, $language),
                    'author' => 'author',
                    'version' => $teaserElementVersion->getVersion(),
                    'create_time' => $teaserElementVersion->getCreatedAt()->format('Y-m-d H:i:s'),
                    'publish_time' => $teaserOnline ? $teaserOnline->getPublishedAt() : '',
                    'custom_date' => $teaserElementVersion->getCustomDate($language),
                    'language' => $language,
                    'sort' => (int) $teaser->getInheritSort($treeId),
                    'version_latest' => (int) $teaserElement->getLatestVersion(),
                    'version_online' => (int) $teaserManager->getPublishedVersion($teaser, $language),
                    'status' => '>o>',
                    'qtip' => $teaserElementVersion->getBackendTitle($language).', Version '.$teaserElementVersion->getElementtypeVersion().'<br>'.
                        'Version '.$teaserElementVersion->getVersion().'<br>',
                ];
            } elseif ('inherited' === $teaser->getType()) {
                $data[] = [
                    'teaser_id' => (int) $teaser->getId(),
                    'eid' => null,
                    '_type' => $teaser->getType(),
                    'title' => 'waaa', //$teaserItem->text,
                    'element_type_id' => 0,
                    'element_type' => '',
                    'navigation' => 0,
                    'restricted' => 0,
                    'icon' => $iconResolver->resolveTeaser($teaser, $language),
                    'author' => 'author',
                    'version' => 0,
                    'create_time' => '',
                    'publish_time' => null,
                    'language' => $language,
                    'sort' => (int) $teaser->getInheritSort($treeId),
                    'version_latest' => 0,
                    'version_online' => 0,
                    'status' => '>o>',
                    'qtip' => 'waaa', //$teaserItem->text,
                ];
            }
        }

        $sorter = array();
        foreach ($data as $index => $teaser) {
            $sortValue = $teaser[$sort];
            if ($sortValue instanceof \DateTimeInterface) {
                $sortValue = $sortValue->format('c');
            }
            if (is_int($sortValue)) {
                $sortType = SORT_NUMERIC;
            } else {
                $sortType = SORT_STRING;
            }
            $sorter[] = $sortValue;
        }
        if ($dir === 'ASC') {
            array_multisort($sorter, SORT_ASC, $sortType, $data);
        } else {
            array_multisort($sorter, SORT_DESC, $sortType, $data);
        }

        //$data['totalChilds'] = $element->getChildCount();

        return new JsonResponse(
            [
                'parent' => $parent,
                'list' => $data,
            ]
        );
    }
946745
public function listElement(Request $request)
    {
        $baseIds = array_keys($this->getAclForUser()->get_granted_base([\ACL::CANADDRECORD]));

        $lazaretFiles = null;
        $perPage = 10;
        $page = max(1, $request->query->get('page', 1));
        $offset = ($page - 1) * $perPage;

        if (count($baseIds) > 0) {
            $lazaretFiles = $this->getLazaretFileRepository()->findPerPage($baseIds, $offset, $perPage);
        }

        return $this->render('prod/upload/lazaret.html.twig', [
            'lazaretFiles' => $lazaretFiles,
            'currentPage'  => $page,
            'perPage'      => $perPage,
        ]);
    }
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));
    }
138566
public function updateTreeAction(Request $request)
    {
        /** @var Request $request */
        $nodes = $request->get('nodes') ? $request->get('nodes') : [];

        $admin = $this->get('networking_init_cms.admin.tag');

        $validator = $this->get('validator');
        try {
            foreach ($nodes as $node) {
                if (!$node['id']) {
                    continue;
                }
                /** @var $tag Tag */
                $tag = $admin->getObject($node['id']);
                if ($node['parent_id']) {
                    $parent = $admin->getObject($node['parent_id']);
                    $tag->setParent($parent);
                } else {
                    $tag->setParent(null);
                }

                $tag->setLevel($node['depth'] + 1);

                $errors = $validator->validate($tag);
                if (count($errors) > 0) {
                    throw new ValidatorException();
                }

                $this->admin->update($tag);
            }

            $response = ['status' => 'success', 'message' => $this->admin->trans('info.tag_sorted')];
        } catch (\Exception $e) {
            $response = ['status' => 'error', 'message' => $this->admin->trans('info.tag_sorted_error')];
        }

        return $this->renderJson($response);
    }
249774
public function getOptions(Request $request)
    {
        $routes = [];

        foreach ($this->routes as $route) {
            if ($route->matchesPattern($request)) {
                $routes[] = $route;
            }
        }

        return $routes;
    }
498035
public function toArray($request)
    {
        return [
            'id'           => (int) $this->id,
            'author_id'    => $this->author_id,
            'type'         => $this->whenLoaded('type', function () {
                return $this->type->name;
            }),
            'region'       => $this->region,
            'theme'        => $this->theme,
            'weight'       => $this->weight,
            'filter'       => $this->filter,
            'options'      => $this->options,
            'is_active'    => $this->is_active,
            'is_cacheable' => $this->is_cacheable,
            'created_at'   => $this->created_at->toIso8601String(),
            'updated_at'   => $this->updated_at->toIso8601String(),
            'translations' => BlockTranslation::collection($this->whenLoaded('translations')),
        ];
    }
188239
public function listSections(Request $request)
    {
        if ($request->query->has('identifier')) {
            $sections = array(
                $this->loadSectionByIdentifier($request),
            );
        } else {
            $sections = $this->sectionService->loadSections();
        }

        return new Values\SectionList($sections, $request->getPathInfo());
    }
18245
public function toArray($request)
    {
        return [
            'id'                 => (int) $this->id,
            'parent_id'          => $this->parent_id,
            'author_id'          => $this->author_id,
            'level'              => $this->level,
            'type'               => $this->whenLoaded('type', function () {
                return $this->type->name;
            }),
            'thumbnail'          => $this->whenLoaded('thumb', function () {
                return new File($this->thumb);
            }),
            'theme'              => $this->theme,
            'weight'             => $this->weight,
            'rating'             => $this->rating,
            'is_on_home'         => $this->is_on_home,
            'is_comment_allowed' => $this->is_comment_allowed,
            'is_promoted'        => $this->is_promoted,
            'is_sticky'          => $this->is_sticky,
            'path'               => $this->buildPath($this->path),
            'published_at'       => optional(dateTimeToRequestTimezone($this->published_at))->toIso8601String(),
            'created_at'         => dateTimeToRequestTimezone($this->created_at)->toIso8601String(),
            'updated_at'         => dateTimeToRequestTimezone($this->updated_at)->toIso8601String(),
            'routes'             => $this->whenLoaded('routes', function () {
                return Route::collection($this->routes);
            }),
            'translations'       => ContentTranslation::collection($this->whenLoaded('translations')),
            'children'           => $this->when(!empty($this->children), function () {
                return Content::collection($this->children);
            }),
        ];
    }