Edit wiki template action

@return \Zend\View\Model\ViewModel
485367
public function editWikiTemplateAction()
    {
        $templateFile = $this->getOptions()->getUseCaseDokuWikiTemplate();

        if (!is_writeable($templateFile)) {
            throw new \RuntimeException(sprintf(
                    'Template file "%s" is not writeable. Please fix the file priviliges first!',
                    $templateFile
            ));
        }

        $request = $this->getRequest();
        $form    = $this->getServiceLocator()->get('dlcusecase_editwikitemplate_form');

        if ($request->getQuery()->get('redirect')) {
            $redirect = $request->getQuery()->get('redirect');
        } else {
            $redirect = false;
        }

        $redirectUrl = $this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/edit-wiki-template')
                     . ($redirect ? '?redirect=' . $redirect : '');

        $prg = $this->prg($redirectUrl, true);

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
                'form' => $form,
                'options'  => $this->getOptions(),
            );
        }

        $post     = $prg;
        $redirect = isset($prg['redirect']) ? $prg['redirect'] : null;

        $form->setData($post);

        if (!$form->isValid()) {
            return array(
                'options'  => $this->getOptions(),
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        $formData = $form->getData();

        file_put_contents($this->getOptions()->getUseCaseDokuWikiTemplate(), $formData['wiki-template']);

        // TODO: Add the redirect parameter here...
        return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/show-wiki-template') . ($redirect ? '?redirect='.$redirect : ''));
    }
1027774
public function indexAction()
    {
        if (!$this->rcmUserService->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        $this->layout()->setTemplate('layout/blank');

        $view = new ViewModel();
        $view->setVariable(
            'siteSettingsSectionDefinitions',
            $this->getSettingsSectionDefinitions->__invoke()
        );

        return $view;
    }
841392
public function toolModalContentAction()
    {
        $id = $this->params()->fromRoute('id', $this->params()->fromQuery('id', ''));

        $melisKey = $this->params()->fromRoute('melisKey', '');
        $title    = $this->tool()->getTranslation('tr_melis_cms_prospects_theme_new_title');
        $data     = array();
        $form     = $this->getThemeForm();

        if(is_numeric($id)) {
            $title = $this->tool()->getTranslation('tr_melis_cms_prospects_theme_edit_title');
            $data  = (array) $this->themeTable()->getEntryById((int) $id)->current();
            $form->setData($data);
        }
        else {
            $form->get('pros_theme_id')->setAttribute('style', 'display:none')->setLabel('');
            $form->get('pros_theme_id')->setLabelAttributes(array('style' => 'display:none'));
        }

        $view = new ViewModel();

        $view->melisKey = $melisKey;
        $view->title    = $title;
        $view->form     = $form;

        return $view;
    }
471604
public function usageAction()
    {
        $this->assign('version', Samurai::getVersion());
        $this->assign('state', Samurai::getState());
        $this->assign('script', './app');   // TODO: $this->request->getScript()
        return self::VIEW_TEMPLATE;
    }
642103
public function renderPlatformContentActionEditAction()
    {
        $melisKey = $this->params()->fromRoute('melisKey', '');
    
        $view = new ViewModel();
        $view->melisKey = $melisKey;
    
        return $view;
    }
1251211
public function renderTreeToolsAction(): ViewModel
    {
        $melisKey = $this->params()->fromRoute('melisKey', '');

        /** @var \MelisCore\Service\MelisCoreConfigService $melisAppConfig */
        $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
        $melisKeys = $melisAppConfig->getMelisKeys();

        // Get the order list for ordering tools
        $appconfigpath = $melisKeys[$melisKey];

        $appsConfig = $melisAppConfig->getItem($appconfigpath);


        $orderInterface = $melisAppConfig->getOrderInterfaceConfig($melisKey);
        $tools = [];

        /** @var \MelisCore\Service\MelisCoreAuthService $melisCoreAuth */
        $melisCoreAuth = $this->getServiceLocator()->get('MelisCoreAuth');

        /** @var \MelisCore\Service\MelisCoreRightsService $melisCoreRights */
        $melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
        $xmlRights = $melisCoreAuth->getAuthRights();

        // Merge config if melisKey is "Others"
        if ($melisKey == 'melisothers_toolstree_section') {
            $appsConfig['interface'] = ArrayUtils::merge($appsConfig['interface'], $this->moveToolsToOthersCategory());
        }

        if (isset($appsConfig['interface']) && !empty($appsConfig['interface'])) {
            // Show sections first

            foreach ($appsConfig['interface'] as $key => $toolSectionName) {
                $isNavChild = false;

                if ($melisCoreRights->canAccess($key)) {

                    $tools[$key] = [
                        'toolsection_id' => $toolSectionName['conf']['id'] ?? $key,
                        'toolsection_name' => $toolSectionName['conf']['name'] ?? $key,
                        'toolsection_meliskey' => $toolSectionName['conf']['melisKey'] ?? $key,
                        'toolsection_icon' => $toolSectionName['conf']['icon'] ?? 'fa-cube',
                        'toolsection_forward' => $toolSectionName['forward'] ?? [],
                        'toolsection_children' => [],
                        'toolsection_is_tool' => isset($toolSectionName['forward']) && !empty($toolSectionName['forward']) ? true : false,
                    ];

                    // Second level, tools
                    if (isset($toolSectionName['interface'])) {
                        foreach ($toolSectionName['interface'] as $keyTool => $toolName) {
                            $isToolNavChild = false;

                            $icon = (!empty($toolName['conf']['icon'])) ? $toolName['conf']['icon'] : 'fa-cube';

                            if ($icon) {
                                $isNavChild = true;
                            }

                            if ($melisCoreRights->canAccess($keyTool)) {
                                $tools[$key]['toolsection_children'][$keyTool] = [
                                    'tool_id' => $toolName['conf']['id'] ?? $keyTool,
                                    'tool_name' => $toolName['conf']['name'] ?? "<strike>$keyTool</strike>",
                                    'tool_icon' => $icon,
                                    'tool_forward' => isset($toolName['forward']) ? $toolName['forward'] : [],
                                    'tool_melisKey' => $toolName['conf']['melisKey'] ?? $keyTool,
                                    'toolsection_is_tool' => isset($toolName['forward']) && !empty($toolName['forward']) ? true : false
                                ];
                            }

                            // add third level for tool others
                            if ($melisKey == 'melisothers_toolstree_section') {
                                if (isset($toolName['interface'])) {

                                    // third level, child tools
                                    foreach ($toolName['interface'] as $childKeyTool => $childToolname) {
                                        $icon = (!empty($childToolname['conf']['icon'])) ? $childToolname['conf']['icon'] : 'fa-cube';

                                        if ($icon) {
                                            $isToolNavChild = true;
                                        }

                                        if ($melisCoreRights->canAccess($childKeyTool)) {
                                            $tools[$key]['toolsection_children'][$keyTool]['toolsection_children'][$childKeyTool] = [
                                                'tool_id' => $childToolname['conf']['id'] ?? $keyTool,
                                                'tool_name' => $childToolname['conf']['name'] ?? "<strike>$childKeyTool</strike>",
                                                'tool_icon' => $icon,
                                                'tool_forward' => isset($childToolname['forward']) ? $childToolname['forward'] : [],
                                                'tool_melisKey' => $childToolname['conf']['melisKey'] ?? $keyTool,
                                                'toolsection_is_tool' => isset($childToolname['forward']) && !empty($childToolname['forward']) ? true : false
                                            ];
                                        }

                                    }

                                }

                            }
                            $tools[$key]['toolsection_children'][$keyTool]['toolsection_has_nav_child'] = $isToolNavChild;
                        }
                    }
                }


                $tools[$key]['toolsection_has_nav_child'] = $isNavChild;
            }
        } else {
            // for parent tool
            if (isset($appsConfig['conf']['is_parent_tool']) && $appsConfig['conf']['is_parent_tool']) {
                if ($melisCoreRights->canAccess($melisKey)) {
                    $tools[$melisKey] = $appsConfig;
                }
            }
        }

        $sections = $tools;

        // Reordering sections
        $toolsOrdered = [];
        foreach ($orderInterface as $orderKeySection => $sectionTools) {
            if (!empty($sections[$orderKeySection])) {
                if (empty($toolsOrdered[$orderKeySection])) {
                    $toolsOrdered[$orderKeySection] = [];
                }
                $toolsOrdered[$orderKeySection] = $tools[$orderKeySection];
                unset($toolsOrdered[$orderKeySection]['toolsection_children']);
                unset($sections[$orderKeySection]);
            }
        }
        foreach ($sections as $keyInterfaceSection => $childinterface) {
            if (empty($toolsOrdered[$keyInterfaceSection])) {
                $toolsOrdered[$keyInterfaceSection] = [];
            }
            $toolsOrdered[$keyInterfaceSection] = $tools[$keyInterfaceSection];
            unset($toolsOrdered[$keyInterfaceSection]['toolsection_children']);
        }

        // Reordering tools inside sections
        foreach ($toolsOrdered as $keySection => $toolsSection) {
            $sectionOrderInterface = [];
            if (!empty($orderInterface[$keySection])) {
                $sectionOrderInterface = $orderInterface[$keySection];
            }
            $toolsSectionOrdered = [];

            foreach ($sectionOrderInterface as $orderKey) {
                if (!empty($tools[$keySection]['toolsection_children'][$orderKey])) {
                    $toolsOrdered[$keySection]['toolsection_children'][$orderKey] = $tools[$keySection]['toolsection_children'][$orderKey];
                    unset($tools[$keySection]['toolsection_children'][$orderKey]);
                }
            }

            if (isset($tools[$keySection]['toolsection_children'])) {
                foreach ($tools[$keySection]['toolsection_children'] as $keyInterface => $childinterface) {
                    $toolsOrdered[$keySection]['toolsection_children'][$keyInterface] = $childinterface;
                }
            }
        }

        $view = new ViewModel();

        $view->tools = $toolsOrdered;
        $view->melisKey = $melisKey;
        return $view;
    }
578836
public function editAction()
    {
        if(method_exists($this, 'getEditForm'))
        {
            $form = $this->getEditForm();
        }
        else
        {
            $form = $this->getForm();
        }

        $id = $this->getEvent()
                ->getRouteMatch()
                ->getParam('id', 0);

        $form->add([
            'type'       => 'Zend\Form\Element\Hidden',
            'name'       => 'id',
            'attributes' => [
                'id'    => 'id',
                'value' => $id,
            ],
            'filters'    => [
                [
                    'name' => 'Int',
                ],
            ],
            'validators' => [
                [
                    'name' => 'Digits',
                ],
            ],
        ]);

        $em            = $this->getEntityManager();
        $objRepository = $em->getRepository($this->getEntityClass());
        $entity        = $objRepository->find($id);
        $form->bind($entity);

        $redirectUrl = $this->url()->fromRoute($this->getActionRoute(), [], true);
        $prg         = $this->fileprg($form, $redirectUrl, true);

        if($prg instanceof Response)
        {
            return $prg;
        }
        elseif($prg === false)
        {
            $this->getEventManager()->trigger('getForm', $this, [
                'form'        => $form,
                'entityClass' => $this->getEntityClass(),
                'id'          => $id,
                'entity'      => $entity,
            ]);

            return [
                'entityForm' => $form,
                'entity'     => $entity,
            ];
        }

        $this->getEventManager()->trigger('getForm', $this, [
            'form'        => $form,
            'entityClass' => $this->getEntityClass(),
            'id'          => $id,
            'entity'      => $entity,
        ]);

        $savedEntity = $this->getEntityService()->save($form, $entity);

        if(!$savedEntity)
        {
            return [
                'entityForm' => $form,
                'entity'     => $entity,
            ];
        }

        $this->flashMessenger()->addSuccessMessage($this->getServiceLocator()
                        ->get('translator')
                        ->translate($this->successEditMessage));

        return $this->redirect()->toRoute($this->getActionRoute('list'), [], true);
    }
936194
public function editProfileAction()
    {
        if(!$user = $this->identity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        
        $form = $this->getUserFormHelper()->createUserForm($user, 'EditProfile');
        $email = $user->getEmail();
        $username = $user->getUsername();
        $message = null;    
        if($this->getRequest()->isPost()) {
            $currentFirstName = $user->getFirstName();
            $currentLastName = $user->getLastName();
            $form->setValidationGroup('firstName', 'lastName', 'language', 'csrf');
            $form->setData($this->getRequest()->getPost());
            if($form->isValid()) {
                $firstName = $this->params()->fromPost('firstName');
                $lastName = $this->params()->fromPost('lastName');
                $user->setFirstName($firstName);
                $user->setLastName($lastName);    
                $entityManager = $this->getEntityManager();
                $entityManager->persist($user);
                $entityManager->flush();    
                $message =  $this->getTranslatorHelper()->translate('Your profile has been edited');
            }
        }
    
        return new ViewModel(array(
            'form' => $form,
            'email' => $email,
            'username' => $username,
            'securityQuestion' => $user->getQuestion()->getQuestion(),
            'message' => $message,
            'navMenu' => $this->getOptions()->getNavMenu()
        ));
    }
395662
public function edit(Request $request)
    {
        $post = $this->api('post.fetch', $request->route('post'))->get();

        event(new UserEditingPost($post));

        if ($post->trashed()) {
            return abort(404);
        }

        $this->authorize('edit', $post);

        $thread = $post->thread;
        $category = $post->thread->category;

        return view('forum::post.edit', compact('category', 'thread', 'post'));
    }
101513
public function edit(Model $page)
    {
        $widgetOptions = Widget::allOptions();

        return view('avored-ecommerce::page.edit')
            ->with('model', $page)
            ->with('widgetOptions', $widgetOptions);
    }
793347
public function edit() {
		HtmlEditorField::include_js();
//		Requirements::javascript('simplewiki/javascript/sslinks/editor_plugin_src.js');

		$existing = $this->getEditingLocks($this->data(), true);
		// oops, we've somehow got here even though we shouldn't have
		if ($existing && $existing['user'] != Member::currentUser()->Email) {
			return $this->redirect($this->data()->Link());
		}

		if (!$this->data()->canEdit()) {
			return Security::permissionFailure($this);
		}

		$this->form = $this->EditForm();

		// check who's editing and whether or not we should bail out
		return $this->renderWith(array('WikiPage', 'Page'));
	}
138286
public function editAction()
    {
        $this->getResponse()->setTypeJson();
        $error = json_encode(['error' => 'Edycja nie powiodła się, brak pliku']);
        //brak id
        if (!$this->id) {
            return $error;
        }
        //brak pliku
        if (null === ($file = (new CmsFileQuery)->findPk($this->id))) {
            return $error;
        }
        //błędny plik
        if ($this->hash != $file->getHashName()) {
            return $error;
        }
        //zapis
        $postData = $this->getPost()->toArray();
        if (!empty($postData)) {
            $file->setFromArray($postData)
                ->save();
        }
        //json na potrzeby wyświetlenia formularza
        return $file->toJson();
    }
850545
public function wysiwygMediaAction()
    {
        $form = $this->createForm(new AdminMediaType($this->container), new Media());
        return $this->render(
            'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig',
            array(
                'form' => $form->createView(),
                'wysiwyg' => $this->getWysiwyg()
            )
        );
    }
931759
public function addAction() {

        $edit_form = $this->container->get("haven_core.category.form_handler")->createNewForm();

        $request = $this->container->get('request_modifier')->setRequest($this->container->get("request"))
                ->slug(array("name"))
                ->getRequest();

        $edit_form->bind($request);

        if ($edit_form->isValid()) {
            $this->container->get("haven_core.category.persistence_handler")->save($edit_form->getData());
            $this->container->get("session")->getFlashBag()->add("success", "create.success");

            return new RedirectResponse($this->container->get('router')->generate(str_replace('update', "list", $this->container->get("request")->get("_route"))));
        }

        $this->container->get("session")->getFlashBag()->add("error", "create.error");

        $template = str_replace(":create.html.twig", ":new.html.twig", $this->container->get("request")->get('_template'));
        $params = array(
            'edit_form' => $edit_form->createView()
        );

        return new Response($this->container->get('templating')->render($template, $params));
    }
1126354
public function renderToolTemplateHeaderAddAction()
    {
        $melisKey = $this->params()->fromRoute('melisKey', '');

        $view = new ViewModel();
        $view->melisKey = $melisKey;

        return $view;
    }
208140
public
    function edit($id)
    {
        return $this->view(["row" => Model::findOrFail($id),'template'=>Template::pluck('title','id')->toArray()], "pages::admin.edit");
        //
    }
1058424
public function Form() {
		// The editing form hasn't been put in place by the 'edit' action
		// so lets just show the status form
		$append = '';
		if (!$this->form) {
			if (WikiPage::$show_edit_button || $this->data()->canEdit()) {
				// create the information form 
				$this->form = $this->StatusForm();
			}
		} else {
			// if we have got an editing form, then we'll add a New Page
			// form if we have permissions to do so
			if (Permission::check(MANAGE_WIKI_PAGES)) {
				$append = $this->CreatePageForm()->forTemplate();
			}
		}

		return $this->form->forTemplate() . $append;
	}