Ejemplo n.º 1
0
 /**
  * @return \Zend\Http\Response
  */
 public function deleteAction()
 {
     $this->deleteFileForm->build();
     if ($this->handleDeletePost($this->deleteFileForm)) {
         $this->flashMessenger()->addSuccessMessage($this->userText->getMessage(EntityName::FILE, Message::DELETE_SUCCESS));
     } else {
         $this->flashMessenger()->addErrorMessage($this->userText->getMessage(EntityName::FILE, Message::DELETE_FAILURE));
     }
     return $this->redirect()->toRoute('filemanager/list', ['dir' => $this->getCurrentPath()]);
 }
 /**
  * @return \Zend\Http\Response
  */
 public function createAction()
 {
     if ($this->handleCreatePost($this->createDirForm)) {
         $msg = $this->userText->getMessage(EntityName::DIRECTORY, Message::CREATE_SUCCESS);
         $this->flashMessenger()->addSuccessMessage($msg);
     } else {
         $msg = $this->userText->getMessage(EntityName::DIRECTORY, Message::CREATE_FAILURE);
         $this->flashMessenger()->addErrorMessage($msg);
     }
     return $this->redirect()->toRoute('filemanager/list', array('dir' => $this->getCurrentPath()));
 }
Ejemplo n.º 3
0
 /**
  * @return \Zend\Http\Response
  */
 public function uploadAction()
 {
     $this->uploadFileForm->build($this->getOrigDir());
     if ($this->handleUploadPost($this->uploadFileForm)) {
         $this->flashMessenger()->addSuccessMessage($this->userText->getMessage(EntityName::FILE, Message::UPLOAD_SUCCESS));
     } else {
         $this->flashMessenger()->addErrorMessage($this->userText->getMessage(EntityName::FILE, Message::UPLOAD_FAILURE));
         foreach ($this->uploadFileForm->getMessages() as $messages) {
             foreach ($messages as $message) {
                 $this->flashMessenger()->addErrorMessage($message);
             }
         }
     }
     return $this->redirect()->toRoute('filemanager/list', ['dir' => $this->getCurrentPath()]);
 }
Ejemplo n.º 4
0
 /**
  * @return ViewModel
  */
 public function indexAction()
 {
     $campaign = $this->campaignRepository->getOneBySecurityKey($this->params('securityKey'));
     if (!$campaign) {
         return $this->redirect()->toRoute(static::ERROR_ROUTE);
     }
     /** @var Request $request */
     $request = $this->getRequest();
     $subscriber = $this->subscriberRepository->getOneByEmailAddress($request->getPost('emailAddress'));
     if (!$subscriber) {
         $subscriber = $this->subscriberRepository->getNewEntity();
     }
     try {
         if ($this->manager->handlePost($subscriber, $campaign)) {
             if ($request->getPost('successUrl')) {
                 return $this->redirect()->toUrl($request->getPost('successUrl'));
             }
             return $this->redirect()->toRoute($this->baseRoute, array('securityKey' => $this->params('securityKey')));
         }
         if ($request->getPost('failureUrl')) {
             return $this->redirect()->toUrl($request->getPost('failureUrl'));
         }
     } catch (Manager\Exception\Db $exc) {
         $feedback = $this->userText->getMessage(EntityName::MESSAGE, Message::SAVE_FAILED);
         $this->currentMessages[FeedbackType::DANGER][] = $feedback;
     }
     $this->layout()->currentMessages = $this->currentMessages;
     return new ViewModel(array('form' => $this->manager->getForm(), 'campaignName' => $campaign->getName()));
 }
Ejemplo n.º 5
0
 /**
  * @return ViewModel|Response
  */
 public function updateAction()
 {
     $campaignId = $this->params('entityId');
     /** @var Campaign $campaign */
     $campaign = $this->campaignRepository->getOneById($campaignId);
     if (!$campaign) {
         return $this->redirect()->toRoute(static::BASE_ROUTE);
     }
     $message = $this->messageRepository->getSystemMessage($campaignId);
     if (!$message) {
         $message = $this->messageRepository->getNewEntity();
     }
     try {
         if ($this->manager->handlePost($campaign, $message)) {
             $msg = $this->userText->getMessage(EntityName::CAMPAIGN, Message::UPDATE_SUCCESS);
             $this->flashMessenger()->addSuccessMessage($msg);
             $this->addSystemMessageMessages();
             return $this->redirect()->toRoute(static::BASE_ROUTE);
         }
     } catch (Manager\Exception\Db $exc) {
         $campaignMsg = $this->userText->getMessage(EntityName::CAMPAIGN, Message::SAVE_FAILED);
         $messageMsg = $this->userText->getMessage(EntityName::MESSAGE, Message::SAVE_FAILED);
         $this->currentMessages[FeedbackType::DANGER][] = $campaignMsg;
         $this->currentMessages[FeedbackType::DANGER][] = $messageMsg;
     }
     $this->layout()->currentMessages = $this->currentMessages;
     return new ViewModel(['form' => $this->manager->getForm(), 'tinyMceLang' => $this->tinyMceLang]);
 }
Ejemplo n.º 6
0
 /**
  * @return ViewModel
  */
 public function updateAction()
 {
     $entity = $this->templateRepository->getOneById($this->params('entityId'));
     if (!$entity) {
         return $this->redirect()->toRoute(static::BASE_ROUTE);
     }
     try {
         if ($this->manager->handlePost($entity)) {
             $msg = $this->userText->getMessage(EntityName::TEMPLATE, Message::UPDATE_SUCCESS);
             $this->flashMessenger()->addSuccessMessage($msg);
             return $this->redirect()->toRoute(static::BASE_ROUTE);
         }
     } catch (Manager\Exception\Db $exc) {
         $msg = $this->userText->getMessage(EntityName::TEMPLATE, Message::SAVE_FAILED);
         $this->currentMessages[FeedbackType::DANGER][] = $msg;
     }
     $this->layout()->currentMessages = $this->currentMessages;
     return new ViewModel(['form' => $this->manager->getForm()]);
 }
Ejemplo n.º 7
0
 /**
  * @return JsonModel
  */
 public function toggleOnHaltAction()
 {
     /** @var EntityMessage $message */
     $message = $this->messageRepository->getOneById($this->params('entityId'));
     if (!$message) {
         return $this->redirect()->toRoute(static::BASE_ROUTE);
     }
     $message->setOnHalt(!$message->isOnHalt());
     $response = $this->getResponse();
     try {
         if ($this->manager->saveEntity($message)) {
             $response->setContent('true');
             return $response;
         }
     } catch (DbException $exc) {
         $msg = $this->userText->getMessage(EntityName::MESSAGE, DmCommonMessage::SAVE_FAILED);
         $this->flashMessenger()->addErrorMessage($msg);
     }
     $this->flashMessenger()->clearCurrentMessages();
     $response->setContent('false');
     return $response;
 }
Ejemplo n.º 8
0
 /**
  * @covers DmCommon\View\Helper\UserText
  */
 public function testGetMessage()
 {
     $result = $this->sut->getMessage(self::ENTITY_KEY, DefinedConstant\Message::SAVE_FAILED);
     $this->assertEquals('Saving Template failed.', $result);
 }