Provides tag children data for tag field edit interface.

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\JsonResponse
979180
public function childrenAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ez:tags:read');

        $subTreeLimit = (int) $request->query->get('subTreeLimit', 0);
        $hideRootTag = (bool) $request->query->get('hideRootTag', false);
        $locale = $request->query->get('locale');

        $tags = $this->tagsService->loadTagChildren(
            !empty($subTreeLimit) ? $this->tagsService->loadTag($subTreeLimit) : null,
            0,
            -1,
            [$locale]
        );

        $data = $this->filterTags($tags, $subTreeLimit, $hideRootTag);

        return new JsonResponse($data);
    }
442589
public function editMarkAction(Request $request, Mark $mark)
    {
        $this->assertCanEdit($mark->getResult());
        $newValue = $request->request->get('value', false);
        $response = new JsonResponse();

        if ($newValue !== false) {
            if (!$this->manager->isValidMark($mark->getResult(), $newValue)) {
                $response->setData('Mark is not valid');
                $response->setStatusCode(422);
            } else {
                $this->manager->updateMark($mark, $newValue);
                $response->setStatusCode(204);
            }
        } else {
            $response->setData('Field "value" is missing');
            $response->setStatusCode(422);
        }

        return $response;
    }
150385
public function loadTagChildren($tagPath, Request $request)
    {
        $offset = $request->query->has('offset') ? (int) $request->query->get('offset') : 0;
        $limit = $request->query->has('limit') ? (int) $request->query->get('limit') : 25;

        $tagId = $this->extractTagIdFromPath($tagPath);
        $children = $this->tagsService->loadTagChildren(
            $tagId !== '0' ?
                $this->tagsService->loadTag($tagId) :
                null,
            $offset >= 0 ? $offset : 0,
            $limit >= 0 ? $limit : 25
        );

        $restTags = [];
        foreach ($children as $tag) {
            $restTags[] = new Values\RestTag($tag, 0, 0);
        }

        return new Values\CachedValue(
            new Values\TagList(
                $restTags,
                $request->getPathInfo()
            ),
            ['tagId' => $tagId]
        );
    }
778712
public function listAction(Request $request)
    {
        $type = $request->get('type', Elementtype::TYPE_FULL);

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');

        $elementtypes = [];
        foreach ($elementtypeService->findAllElementtypes() as $elementtype) {
            if ($type !== $elementtype->getType()) {
                continue;
            }

            if ($elementtype->getDeleted()) {
                continue;
            }

            $elementtypes[$elementtype->getTitle().$elementtype->getId()] = [
                'id' => $elementtype->getId(),
                'title' => $elementtype->getTitle(),
                'icon' => $elementtype->getIcon(),
                'version' => $elementtype->getRevision(),
                'type' => $elementtype->getType(),
            ];
        }

        ksort($elementtypes);
        $elementtypes = array_values($elementtypes);

        $checker = $this->get('phlexible_element.checker');
        $changes = $checker->check();
        $hasChanges = false;
        foreach ($changes as $change) {
            if ($change->getNeedImport()) {
                $hasChanges = true;
                break;
            }
        }

        return new JsonResponse([
            'elementtypes' => $elementtypes,
            'total' => count($elementtypes),
            'changes' => $hasChanges,
        ]);
    }
791523
public function fieldsAction(Request $request)
    {
        $id = $request->get('id');

        $metaSetManager = $this->get('phlexible_meta_set.meta_set_manager');
        $metaSet = $metaSetManager->find($id);
        $fields = $metaSet->getFields();

        $data = [];
        foreach ($fields as $field) {
            $data[] = [
                'id' => $field->getId(),
                'key' => $field->getName(),
                'type' => $field->getType(),
                'required' => $field->isRequired(),
                'synchronized' => $field->isSynchronized(),
                'readonly' => $field->isReadonly(),
                'options' => $field->getOptions(),
            ];
        }

        return new JsonResponse(['values' => $data]);
    }
935235
public function editAction(Request $request): Response
    {
        /* @todo it shouldn't rely on keys from request */
        $requestKeys = $request->request->keys();
        $formName = reset($requestKeys) ?: null;

        $form = $this->formFactory->contentEdit(null, $formName);
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentEditData $data) {
                $contentInfo = $data->getContentInfo();
                $versionInfo = $data->getVersionInfo();
                $language = $data->getLanguage();
                $versionNo = $versionInfo->versionNo;
                $location = $data->getLocation();

                $content = $this->contentService->loadContent($contentInfo->id);
                if ((new ContentIsUser($this->userService))->isSatisfiedBy($content)) {
                    return $this->redirectToRoute('ez_user_update', [
                        'contentId' => $contentInfo->id,
                        'versionNo' => $versionNo,
                        'language' => $language->languageCode,
                    ]);
                }

                if (!$versionInfo->isDraft()) {
                    $contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo);
                    $this->updateDraftInitialLanguage($contentDraft, $language);
                    $versionNo = $contentDraft->getVersionInfo()->versionNo;

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("New Version Draft for '%name%' created.") */
                            'content.create_draft.success',
                            ['%name%' => $contentInfo->name],
                            'content'
                        )
                    );
                }

                return $this->redirectToRoute('ez_content_draft_edit', [
                    'contentId' => $contentInfo->id,
                    'versionNo' => $versionNo,
                    'language' => $language->languageCode,
                    'locationId' => null !== $location
                        ? $location->id
                        : $contentInfo->mainLocationId,
                ]);
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        /** @var ContentEditData $data */
        $data = $form->getData();
        $contentInfo = $data->getContentInfo();

        if (null !== $contentInfo) {
            return $this->redirectToRoute('_ezpublishLocation', [
                'locationId' => $contentInfo->mainLocationId,
            ]);
        }

        return $this->redirectToRoute('ezplatform.dashboard');
    }
604948
public function getTagByUrl($request)
    {
        $this->resort();
        foreach ($this->requests as $url=>$tag) {
            if (0 === strrpos($request, $url)) return $tag;
        }
        return null;
    }
681572
public function edit($request) {
        $controller=$this->getToplevelController();
        $form=$this->ItemEditForm($this->gridField, $request);
        
        
        return $controller->customise(array(
                                    'Title'=>($this->record && $this->record->ID ? $this->record->Title:sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->i18n_singular_name())),
                                    'ItemEditForm'=>$form,
                                ))->renderWith($this->template);
    }
772825
public function updatetreenodes($request) {
        $data=array();
        $ids=explode(',', $request->getVar('ids'));
        foreach($ids as $id) {
            if($id==Session::get('CodeBank.deletedSnippetID')) {
                Session::clear('CodeBank.deletedSnippetID');
                $this->response->addHeader('Content-Type', 'text/json');
                return '{"'.$id.'": false}';
            }
            $record=$this->getRecord($id);
            $recordController=singleton('CodeBank');
            
            //Find the next & previous nodes, for proper positioning (Sort isn't good enough - it's not a raw offset)
            $next=$prev=null;
            $className=$this->stat('tree_class');
            $next=Snippet::get()->filter('LanguageID', $record->LanguageID)->filter('FolderID', $record->FolderID)->filter('Title:GreaterThan', $record->Title)->first();
            if(!$next) {
                $prev=Snippet::get()->filter('LanguageID', $record->LanguageID)->filter('FolderID', $record->FolderID)->filter('Title:LessThan', $record->Title)->reverse()->first();
            }
            
            $link=Controller::join_links($recordController->Link("show"), $record->ID);
            $html=CodeBank_TreeNode::create($record, $link, $this->isCurrentPage($record))->forTemplate().'</li>';
            
            $folder=$record->Folder();
            $data[$id]=array(
                            'html'=>$html,
                            'ParentID'=>(!empty($folder) && $folder!==false && $folder->ID!=0 ? 'folder-'.$record->FolderID:'language-'.$record->LanguageID),
                            'NextID'=>($next ? $next->ID:null),
                            'PrevID'=>($prev ? $prev->ID:null)
                        );
        }
        
        $this->response->addHeader('Content-Type', 'text/json');
        return Convert::raw2json($data);
    }
248837
public function getAddonFieldsAction(Request $request)
    {
        return $this->handleView(
            $this->view(
                array_values($this->getFieldDescriptors($this->getLocale($request), true)),
                200
            )
        );
    }
815428
public function editAction(Request $request)
    {
        $entityManager = $this->getDoctrine()->getManager();
        /** @var GlobalConfigRepository $globalConfigRepository */
        $globalConfigRepository = $entityManager->getRepository(GlobalConfig::class);
        $globalConfig = $globalConfigRepository->findLast() ?: new GlobalConfig();
        $form = $this->createForm(GlobalConfigType::class, $globalConfig, []);
        $initialLogo = $globalConfig->getLogo();
        $form->handleRequest($request);

        $success = true;
        if ($form->isSubmitted()) {
            if (true === $success = $form->isValid()) {
                //cloning the entity will give it a new id in order to invalidate browser cache (in meta.html.twig)
                $entityManager->clear(GlobalConfig::class);
                $entityManager->persist($globalConfig);
                $entityManager->flush();
                if ($initialLogo !== $globalConfig->getLogo() && $globalConfig->getLogo() !== null) {
                    $this->container->get(FaviconGenerator::class)->generate(
                        $globalConfig,
                        $this->getParameter('kernel.project_dir').'/faviconConfig.json'
                    );
                }
                $this->congrat('victoire.config.global.edit.success');

                return new JsonResponse([
                    'url'     => $this->generateUrl('victoire_core_homepage_show'),
                    'success' => true,
                ]);
            }
        }

        return new JsonResponse([
            'html' => $this->renderView('VictoireConfigBundle:global:edit.html.twig', [
                'form' => $form->createView(),
            ]),
            'success' => $success,
        ]);
    }
1116185
protected function handleWriteTag($request, $id = null)
    {
        $tag = $id ? $this->getTag($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_tag', $tag, [
            'csrf_protection' => false,
        ]);

        FormHelper::removeFields($request->request->all(), $form);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $tag = $form->getData();
            $this->tagManager->save($tag);

            $context = new Context();
            $context->setGroups(['sonata_api_read']);

            $view = FOSRestView::create($tag);
            $view->setContext($context);

            return $view;
        }

        return $form;
    }
803984
public function inlineEditAction(Request $request)
    {
        $values = $request->request->all();

        $adminListConfigurator = $this->getAdminListConfigurator();
        if (!$adminListConfigurator->canEditInline($values)) {
            throw $this->createAccessDeniedException('Not allowed to edit this translation');
        }

        $id = isset($values['pk']) ? (int) $values['pk'] : 0;
        $em = $this->getDoctrine()->getManager();
        /**
         * @var TranslatorInterface
         */
        $translator = $this->container->get('translator');

        try {
            if ($id !== 0) {
                // Find existing translation
                $translation = $em->getRepository('KunstmaanTranslatorBundle:Translation')->find($id);

                if (is_null($translation)) {
                    return new Response($translator->trans('translator.translator.invalid_translation'), 500);
                }
            } else {
                // Create new translation
                $translation = new Translation();
                $translation->setDomain($values['domain']);
                $translation->setKeyword($values['keyword']);
                $translation->setLocale($values['locale']);
                $translation->setTranslationId($values['translationId']);
            }
            $translation->setText($values['value']);
            $em->persist($translation);
            $em->flush();

            return new JsonResponse([
                'success' => true,
                'uid' => $translation->getId(),
            ], 200);
        } catch (\Exception $e) {
            return new Response($translator->trans('translator.translator.fatal_error_occurred'), 500);
        }
    }
856787
public function ajaxTagAction(Request $request)
    {
        // if ($request->isXmlHttpRequest()) {
            $em = $this->getDoctrine()->getManager();
            if ($request->getMethod() == "GET") {
                $tags = $this->get('okto_media_tag')->findAll();
                $json = [];
                foreach ($tags as $tag) {
                    $json[] = $tag->getText();
                }
                return new Response(json_encode($json));
            }
        // }
        return $this->redirect('oktothek_tag_index');
    }
928582
public function getElementHtml(Request $request)
    {
        $attributes = $this->repository->findMany($request->get('attribute_id'));

        $tmpString = '__RANDOM__STRING__';
        $view = view('avored-ecommerce::attribute.get-element')
            ->with('attributes', $attributes)
            ->with('tmpString', $tmpString);

        return new JsonResponse(['success' => true, 'content' => $view->render()]);
    }
769925
public function editVariation(Request $request)
    {
        $product = Product::findorfail($request->get('variation_id'));
        $view = view('avored-framework::product.variation-modal')
                            ->with('model', $product);

        return new JsonResponse(
            ['success' => true,
            'content' => $view->render(),
            'modalId' => '#variation-modal-' . $product->id]
        );
    }
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);
    }