/**
  * Perform the publish node action
  */
 public function indexAction(Cms $cms, $locale, $site, $revision, $node)
 {
     if (!$cms->resolveNode($site, $revision, $node)) {
         return;
     }
     $this->setContentLocale($locale);
     $cms->setLastAction(self::NAME);
     $translator = $this->getTranslator();
     $defaultRevision = $cms->getDefaultRevision();
     $data = array('revision' => $defaultRevision, 'recursive' => true);
     $revisions = $site->getRevisions();
     if (!isset($revisions[$defaultRevision])) {
         $revisions[$defaultRevision] = $defaultRevision;
     }
     unset($revisions[$node->getRevision()]);
     $form = $this->createFormBuilder($data);
     $form->addRow('revision', 'select', array('label' => $translator->translate('label.revision'), 'description' => $translator->translate('label.revision.publish.description'), 'options' => $revisions, 'validators' => array('required' => array())));
     $form->addRow('recursive', 'option', array('label' => $translator->translate('label.recursive'), 'description' => $translator->translate('label.recursive.publish.description')));
     $referer = $this->request->getQueryParameter('referer');
     $form = $form->build();
     if ($form->isSubmitted()) {
         try {
             $form->validate();
             $data = $form->getData();
             $cms->publishNode($node, $data['revision'], $data['recursive']);
             $this->addSuccess('success.node.published', array('node' => $node->getName($locale), 'revision' => $data['revision']));
             $url = $this->getUrl(self::ROUTE, array('site' => $site->getId(), 'revision' => $node->getRevision(), 'locale' => $locale, 'node' => $node->getId()));
             if ($referer) {
                 $url .= '?referer=' . urlencode($referer);
             }
             $this->response->setRedirect($url);
             return;
         } catch (ValidationException $validationException) {
             $this->setValidationException($validationException, $form);
         }
     }
     $this->setTemplateView('cms/backend/node.publish', array('site' => $site, 'node' => $node, 'form' => $form->getView(), 'referer' => $referer, 'locale' => $locale, 'locales' => $cms->getLocales()));
 }
Пример #2
0
 /**
  * Action to publish a revision 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 publishAction(Cms $cms, $site, $revision, $locale)
 {
     if (!$cms->resolveNode($site, $revision)) {
         return;
     }
     $this->setContentLocale($locale);
     $publishRevision = $cms->getDefaultRevision();
     $cms->publishNode($site, $publishRevision, true);
     $this->addSuccess('success.node.published', array('node' => $site->getName($locale), 'revision' => $publishRevision));
     $referer = $this->request->getQueryParameter('referer');
     if (!$referer) {
         $referer = $this->getUrl('cms.site.detail', array('site' => $site->getId(), 'revision' => $revision, 'locale' => $locale));
     }
     $this->response->setRedirect($referer);
 }