/** * Action to manage the trash of a site * @param \ride\web\cms\Cms $cms Facade to the CMS * @param string $site Id of the site * @param string $revision Name of the revision to work with * @param string $locale Code of the locale * @return null */ public function trashAction(Cms $cms, $site, $revision, $locale) { if (!$cms->resolveNode($site, $revision)) { return; } $this->setContentLocale($locale); $translator = $this->getTranslator(); $referer = $this->request->getQueryParameter('referer'); $trashNodeOptions = array(); $trashNodes = $cms->getTrashNodes($site->getId()); foreach ($trashNodes as $trashNodeId => $trashNode) { $trashNodeOptions[$trashNodeId] = $trashNode->getNode()->getName($locale) . ' (' . date('Y-m-d H:i:s', $trashNode->getDate()) . ')'; } $form = $this->createFormBuilder(); $form->addRow('nodes', 'option', array('label' => $translator->translate('label.nodes.trash'), 'description' => $translator->translate('label.nodes.trash.description'), 'options' => $trashNodeOptions, 'multiple' => true, 'validators' => array('required' => array()))); $form->addRow('destination', 'select', array('label' => $translator->translate('label.destination'), 'description' => $translator->translate('label.destination.restore.description'), 'options' => $cms->getNodeList($site, $locale, true))); $form = $form->build(); if ($form->isSubmitted()) { try { $form->validate(); $data = $form->getData(); $restoreNodes = array(); foreach ($data['nodes'] as $trashNodeId => $trashNodeName) { $restoreNodes[] = $trashNodes[$trashNodeId]; } $cms->restoreTrashNodes($site, $restoreNodes, $data['destination']); $this->response->setRedirect($referer); return; } catch (ValidationException $exception) { $this->setValidationException($exception, $form); } } $this->setTemplateView('cms/backend/site.trash', array('referer' => $referer, 'site' => $site, 'node' => $site, 'form' => $form->getView(), 'trashNodes' => $trashNodes, 'locale' => $locale, 'locales' => $cms->getLocales())); }