コード例 #1
1
 /**
  * Processes formular data
  * 
  * @return \Zend\View\Model\ViewModel
  */
 public function formAction()
 {
     $services = $this->getServiceLocator();
     $repository = $services->get('repositories')->get('Applications/Application');
     $mode = $this->params()->fromQuery('mode', 'new');
     $appId = $this->params()->fromQuery('id');
     $viewModel = new ViewModel();
     if ('edit' == $mode) {
         //$application = $repository->findByCommentId($appId);
         $comment = $repository->findComment($appId);
     } else {
         $comment = new Comment();
         $comment->setUser($this->auth()->getUser());
     }
     $this->acl($application, 'read');
     $form = $services->get('forms')->get('Applications/CommentForm');
     $form->bind($comment);
     if ($this->getRequest()->isPost()) {
         $form->setData($_POST);
         if ($form->isValid()) {
             if ('new' == $mode) {
                 $application = $repository->find($appId);
                 $application->comments->add($comment);
             }
             $viewModel->setVariable('isSaved', true);
         }
     }
     $viewModel->setVariables(array('mode' => $mode, 'identifier' => $appId, 'commentForm' => $form));
     return $viewModel;
 }
コード例 #2
1
ファイル: Update.php プロジェクト: Indigo1337/c4d
 public function updateAction()
 {
     $request = $this->getRequest();
     $recipe = $this->readService->findById($this->params('id'));
     if (false === $this->authorizationService->isGranted('recipe.manage', $recipe)) {
         throw new UnauthorizedException('Insufficient Permissions');
     }
     $viewModel = new ViewModel();
     $viewModel->setTemplate('recipe/update');
     $viewModel->setVariables(['form' => $this->form]);
     $this->form->bind($recipe);
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             try {
                 $this->writeService->save($this->form->getData());
                 $this->flashMessenger()->addSuccessMessage('Rezept erfolgreich aktualisiert');
                 $this->redirect()->toRoute('recipe/read/update', ['id' => $this->params('id')]);
             } catch (\Exception $e) {
                 var_dump($e->getMessage());
             }
         }
     }
     $this->layout('layout/backend');
     return $viewModel;
 }
コード例 #3
1
ファイル: KartController.php プロジェクト: kaiocesar/kart
 public function saveAction()
 {
     $form = $this->getForm();
     $request = $this->getRequest();
     $id = $this->params('id');
     if ($request->isPost()) {
         $data = $request->getPost();
         $form->setData($data);
         $kart = new Kart();
         $form->setInputFilter($kart->getInputFilter());
         if ($form->isValid()) {
             try {
                 $kart->exchangeArray($form->getData());
                 $this->serviceLocator->get('karts')->save($kart->getArrayCopy());
             } catch (\Exception $e) {
             }
             return $this->redirect()->toRoute('application/default', ['controller' => 'kart']);
         }
     } elseif ($id) {
         $kartData = $this->serviceLocator->get('karts')->findById($id);
         $form->setData($kartData);
     }
     $viewModel = new ViewModel();
     $viewModel->setVariables(['form' => $form]);
     $viewModel->setTemplate('application/kart/form.phtml');
     return $viewModel;
 }
コード例 #4
0
ファイル: General.php プロジェクト: arbi/MyCode
 public function indexAction()
 {
     /** @var \DDD\Service\Parking\General $parkingGeneralService */
     $parkingGeneralService = $this->getServiceLocator()->get('service_parking_general');
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $hasAMM = $auth->hasRole(Roles::ROLE_APARTMENT_MANAGEMENT);
     $form = $this->getForm();
     $form->prepare();
     $viewModel = new ViewModel();
     $textline = $active = 0;
     $parkingPermit = '';
     if ($this->parkingLotId) {
         $generalInfo = $parkingGeneralService->getParkingById($this->parkingLotId);
         $usages = iterator_to_array($parkingGeneralService->getUsages($this->parkingLotId));
         foreach ($usages as $usage) {
             $usage['link'] = '<a href="' . $this->url()->fromRoute('apartment/general', ['apartment_id' => $usage['id']]) . '"  target="_blank">
                     <span class="glyphicon glyphicon-share"></span> ' . $usage['name'] . '</a>';
         }
         if (!$generalInfo) {
             Helper::setFlashMessage(['error' => 'Parking lot not found']);
             return $this->redirect()->toRoute('parking/lots');
         }
         $textline = $generalInfo->getDirectionTextlineId();
         $parkingPermit = $generalInfo->getParkingPermit();
         $active = $generalInfo->isActive();
         $viewModel->setVariables(['hasAMM' => $hasAMM, 'usages' => $usages]);
     }
     $uploadForm = new ParkingUpload('parking-permit');
     $viewModel->setVariables(['parkingLotId' => $this->parkingLotId, 'form' => $form, 'textlineId' => $textline, 'parkingPermit' => $parkingPermit, 'isActive' => $active, 'uploadForm' => $uploadForm]);
     return $viewModel;
 }
コード例 #5
0
ファイル: DefaultController.php プロジェクト: evolic/loculus
 public function __construct()
 {
     $event = $this->getEvent();
     $this->viewModel = $event->getViewModel();
     $sharedEvents = StaticEventManager::getInstance();
     $sharedEvents->attach('Zend\\Mvc\\Controller\\AbstractActionController', MvcEvent::EVENT_DISPATCH, function (Event $event) {
         // get view model for layout
         $view = $event->getViewModel();
         // assign locales information
         $sm = $this->getServiceLocator();
         $config = $sm->get('Configuration');
         $view->setVariable('locale', $sm->get('translator')->getLocale());
         $view->setVariable('locales', $config['locales']['list']);
         // assign flashmessanger messages
         $messages = $this->flashmessenger()->getSuccessMessages();
         $view->setVariable('messages', $messages);
         $info = $this->flashmessenger()->getInfoMessages();
         $view->setVariable('info', $info);
         $warnings = $this->flashmessenger()->getMessages();
         $view->setVariable('warnings', $warnings);
         $errors = $this->flashmessenger()->getErrorMessages();
         $view->setVariable('errors', $errors);
         // assign variables to action view
         $this->viewModel->setVariables($view->getVariables());
     });
 }
コード例 #6
0
ファイル: Module.php プロジェクト: sanPgut/SupportCoursZF2
 public function onBootstrap(EventInterface $e)
 {
     // Récupération des erreurs en ajoutant un callback qui affiche l'erreur coté serveur
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
     $event->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         $services = $e->getApplication()->getServiceManager();
         $session = $services->get('session');
         $rightViewModel = new ViewModel();
         if (!isset($session->user)) {
             $form = $services->get('MiniModule\\Form\\Authentification');
             $formUser = $services->get('MiniModule\\Form\\NewUser');
             $rightViewModel->setVariables(array('form' => $form, 'newUserForm' => $formUser));
             $rightViewModel->setTemplate('layout/form-auth');
         } else {
             $rightViewModel->setVariables(array('user' => $session->user));
             $rightViewModel->setTemplate('layout/info-auth');
         }
         $view = $e->getViewModel();
         // c'est le viewModel qui contient le layout (top viewModel)
         $view->addChild($rightViewModel, 'formulaireAuth');
     });
 }
コード例 #7
0
ファイル: ChannelConnection.php プロジェクト: arbi/MyCode
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Cubilis\Connection $cubilisConnectionService
      * @var General $apartmentGeneralService
      */
     $cubilisConnectionService = $this->getServiceLocator()->get('service_cubilis_connection');
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $cubilisDetails = $apartmentGeneralService->getCubilisDetailsAsArray($this->apartmentId);
     $form = new CubilisConnection($this->url()->fromRoute('apartment/channel-connection/save', ['apartment_id' => $this->apartmentId]));
     $form->prepare();
     $form->populateValues($cubilisDetails);
     $formTemplate = 'form-templates/cubilis-connection';
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form]);
     $viewModelForm->setTemplate($formTemplate);
     $rates = $apartmentGeneralService->getRoomRates($this->apartmentId);
     $rateConnections = $cubilisConnectionService->getCubilisTypes($this->apartmentId, $rates);
     $urlLinkRates = $this->url()->fromRoute('apartment/channel-connection/link', ['apartment_id' => $this->apartmentId]);
     $apartmentOTAService = $this->getServiceLocator()->get('service_apartment_ota_distribution');
     $apartmentOTAList = $apartmentOTAService->getOTAList($this->apartmentId);
     $partnerList = $apartmentOTAService->getPartnerList();
     $hasApartmentConnectionRole = false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if ($auth->hasRole(Roles::ROLE_APARTMENT_CONNECTION)) {
         $hasApartmentConnectionRole = true;
     }
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'rateConnections' => $rateConnections, 'rates' => $rates, 'urlLinkRates' => $urlLinkRates, 'cubilisDetails' => $cubilisDetails, 'apartmentOTAList' => $apartmentOTAList, 'partnerList' => $partnerList, 'OTAStatus' => Objects::getOTADistributionStatusList(), 'isCubilisConnecter' => $hasApartmentConnectionRole]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/channel-connection/index');
     return $viewModel;
 }
コード例 #8
0
 public function editAction()
 {
     $entityManager = $this->getOM();
     $viewmodel = new ViewModel();
     $ud = $this->zfcUserAuthentication()->getIdentity()->getId();
     $staff = $this->getOM()->getRepository('Admin\\Entity\\Staff')->findOneBy(array('user' => $ud));
     $id = $staff->getId();
     if (!$id) {
         return $this->redirect()->toRoute('teachers', array('controller' => 'teachers', 'action' => 'dashboard'));
     }
     $image = $staff->getImage();
     $form = new StaffForm($entityManager);
     $form->bind($staff);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $dataForm = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form->setData($dataForm);
         //exclude section and year from being validated
         $form->setValidationGroup(array('staff' => array('fname', 'lname', 'mname', 'mobile1', 'mobile2', 'twitter', 'facebook', 'paddress', 'raddress', 'country', 'email', 'state', 'lga', 'image', 'dob', 'sex', 'religion', 'nokName', 'nokRel', 'nokMobile')));
         if ($form->isValid()) {
             $data = $form->getData('staff')->getImage();
             if (!$data) {
                 $staff->setImage($image);
             }
             $entityManager->persist($staff);
             $entityManager->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('teachers', array('controller' => 'students', 'action' => 'dashboard'));
         }
     }
     $viewmodel->setVariables(array('form' => $form, 'id' => $id, 'image' => $image));
     return $viewmodel;
 }
コード例 #9
0
ファイル: PreciosController.php プロジェクト: jalvarez14/hva
 function comprasbyarticulovarianteAction()
 {
     //Cachamos los datos de la url
     $idarticulovariante = $this->params()->fromQuery('idarticulovariante');
     $descripcion = $this->params()->fromQuery('descripcion');
     $modalName = 'modal-producto-' . $idarticulovariante . '-compras';
     $producto = array();
     $articuloVariante = \ArticulovarianteQuery::create()->findPk($idarticulovariante);
     $producto['nombre'] = $articuloVariante->getArticulo()->getArticuloNombre();
     $producto['descripcion'] = $descripcion;
     $producto['imagen'] = $articuloVariante->getArticulovarianteImagen();
     //Ahora las compras
     $compras = array();
     $compraDetalle = \OrdencompradetalleQuery::create()->filterByIdarticulovariante($idarticulovariante)->useOrdencompraQuery()->filterByIdproveedor(1, \Criteria::NOT_EQUAL)->endUse()->find();
     foreach ($compraDetalle as $kcd => $vcd) {
         $tmp = array();
         $tmp['costo'] = $vcd->getOrdencompradetalleCosto();
         $tmp['fecha'] = $vcd->getOrdencompra()->getOrdencompraFecha('d-m-Y');
         $tmp['proveedor'] = $vcd->getOrdencompra()->getProveedor()->getProveedorNombre();
         array_push($compras, $tmp);
     }
     //var_dump($this->flashMessenger()->getMessages());
     $viewModel = new ViewModel();
     $viewModel->setTerminal(true);
     $viewModel->setVariables(array('modalName' => $modalName, 'producto' => $producto, 'compras' => $compras));
     return $viewModel;
 }
コード例 #10
0
 public function indexAction()
 {
     $pageId = (int) $this->params()->fromRoute('pageId');
     $lang = $this->params()->fromRoute('lang');
     $queryParams = $this->params()->fromQuery();
     if (!is_array($queryParams)) {
         $queryParams = array();
     }
     $queryParams['lang'] = $lang;
     $page = $this->fetchPage($pageId, $queryParams, true);
     if ($page instanceof Page) {
         $viewVariables = $page->getData();
         $template = $page->getTemplate();
         if ((bool) $queryParams['debug']) {
             return new JsonModel($viewVariables);
         }
         if ($template->isValid()) {
             $this->setPageAssets($template, $viewVariables);
             $view = new ViewModel();
             $view->setTemplate($template->getMainFile(false));
             $view->setVariables($viewVariables);
             $view->setTerminal(true);
             return $view;
         }
     }
     $this->getResponse()->setStatusCode(404);
 }
コード例 #11
0
 public function indexAction()
 {
     $viewModel = new ViewModel();
     /* @var $userService \User\Service\User */
     $userService = $this->getServiceLocator()->get('User\\Service\\User');
     $user = $userService->getUser();
     //         $form = $this->getServiceLocator()->get('User\Form\ChangePassword');
     $avatar = new \User\Form\ProfileFile('upload-file');
     $translator = $this->getServiceLocator()->get('translator');
     if (!file_exists(MEDIA_PATH . '/user')) {
         mkdir(MEDIA_PATH . '/user');
         chmod(MEDIA_PATH . '/user', 0777);
     }
     if (!file_exists(MEDIA_PATH . '/user/avatar')) {
         mkdir(MEDIA_PATH . '/user/avatar');
         chmod(MEDIA_PATH . '/user/avatar', 0777);
     }
     $files = scandir(MEDIA_PATH . '/user/avatar');
     $fileavatar = '';
     foreach ($files as $f) {
         if ($this->user()->getIdentity() == explode('.', $f)[0]) {
             $fileavatar = $f;
         }
     }
     $message = '';
     $viewModel->setVariables(['userService' => $userService, 'user' => $user, 'fileavatar' => $fileavatar, 'avatar' => $avatar, 'message' => $message]);
     return $viewModel;
 }
コード例 #12
0
ファイル: UserController.php プロジェクト: petresevic/test
 public function indexAction()
 {
     $userResult = $this->getMpayManager()->getConnector()->userSearch($this->getMpayManager()->getAccessToken());
     $viewModel = new ViewModel();
     $viewModel->setVariables(array('users' => $userResult['data']['users']));
     return $viewModel;
 }
コード例 #13
0
 /**
  * Login action for backoffice..
  *
  * @return ViewModel
  */
 public function loginAction()
 {
     $view = new ViewModel();
     $form = $this->getServiceLocator()->get('FormElementManager')->get('admin.form.login');
     $failed = null;
     if ($this->getRequest()->isPost()) {
         $data = $this->params()->fromPost();
         $form->setData($data);
         $logger = $this->getServiceLocator()->get('logger');
         if ($form->isValid()) {
             // Go to service and check credentials
             $data = $form->getData();
             $result = $this->getServiceLocator()->get('core.service.registration')->login($data['email'], $data['password']);
             if ($result->isValid()) {
                 $session = new Container('locale');
                 $session->locale = $result->getIdentity()->getLanguage();
                 $logger->info('User ' . $result->getIdentity()->getNameSurname() . ' has been logged in to backoffice');
                 $this->redirect()->toUrl('/');
             } else {
                 $failed = _('Authentication failed. Please check your credentials.');
                 $logger->info('Login attempt failed.', $data);
             }
         }
     }
     $view->setVariables(array('loginForm' => $form, 'failed' => $failed));
     return $view;
 }
コード例 #14
0
 public function indexAction()
 {
     $this->_mainParam["data"]["id"] = $this->params("id");
     $display = $this->params("display", "list");
     $viewModel = new ViewModel();
     //view chính
     $bookView = new ViewModel();
     //view -hiện danh sách book
     $bookView->setTemplate('shop/category/' . $display);
     //CATEGORY INFO
     $categoryItem = $this->getTable()->getItem($this->_mainParam["data"]);
     if (empty($categoryItem)) {
         $this->redirect()->toRoute("shopRoute/default", array("controller" => "notice", "action" => "no-data"));
     }
     //BREADCRUMB
     $listBreadcumb = $this->getTable()->listItem($categoryItem, array("task" => "list-breadcrumb"));
     //LISTBOOK BY CATEGORY
     $catIDs = $this->getTable()->listItem($categoryItem, array("task" => "list-id-category"));
     $this->_mainParam["catIDs"] = $catIDs;
     $bookTable = $this->getServiceLocator()->get("shopBookTable");
     $listBook = $bookTable->listItem($this->_mainParam, array("task" => "list-book-by-category"));
     $totalItem = $bookTable->countItem($catIDs, array("task" => "count-book"));
     $viewModel->addChild($bookView, "list_book_category");
     $bookView->setVariables(array("listBook" => $listBook));
     $viewModel->setVariables(array("categoryItem" => $categoryItem, "listBreadcumb" => $listBreadcumb, "paginator" => \ZendVN\Paginator\Paginator::createPagination($totalItem, $this->_configPaginator), "displayType" => $display, "paramSetting" => $this->_mainParam));
     return $viewModel;
 }
コード例 #15
0
ファイル: General.php プロジェクト: arbi/MyCode
 /**
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Apartment\General $apartmentGeneralService
      */
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $form = $this->getForm();
     $form->prepare();
     $generalInfo = false;
     if ($this->apartmentId) {
         $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId);
         $form->populateValues(['id' => $this->apartmentId, 'apartment_name' => $generalInfo['name'], 'status' => $generalInfo['status'], 'room_count' => $generalInfo['room_count'], 'square_meters' => $generalInfo['square_meters'], 'max_capacity' => $generalInfo['max_capacity'], 'bedrooms' => $generalInfo['bedroom_count'], 'bathrooms' => $generalInfo['bathroom_count'], 'chekin_time' => date('H:i', strtotime($generalInfo['check_in'])), 'chekout_time' => date('H:i', strtotime($generalInfo['check_out'])), 'general_description_textline' => $generalInfo['general_descr'], 'general_description' => $generalInfo['general_description']]);
     } else {
         // Pre-filled default values when adding apartment
         $form->populateValues(['chekin_time' => '15:00', 'chekout_time' => '11:00']);
     }
     // passing form and map to the view
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form, 'date_created' => isset($generalInfo['create_date']) ? $generalInfo['create_date'] : '', 'apartmentStatus' => $this->apartmentStatus]);
     $viewModelForm->setTemplate('form-templates/general');
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartment' => $generalInfo, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/general/index');
     return $viewModel;
 }
コード例 #16
0
ファイル: ErrorController.php プロジェクト: petresevic/test
 public function error403Action()
 {
     $this->getResponse()->setStatusCode(403);
     $viewModel = new ViewModel();
     $viewModel->setVariables(array());
     return $viewModel;
 }
コード例 #17
0
 public function indexAction()
 {
     $viewModel = new ViewModel();
     $ad_id = $this->params()->fromRoute('id');
     $adTable = $this->getServiceLocator()->get('AdTable');
     if ($ad_id) {
         //image table to get images for add
         $imageTable = $this->getServiceLocator()->get('ImageTable');
         //get ad content
         $ads_to_show = $adTable->getSingleAd($ad_id);
         //get images for this ad
         $images = $imageTable->getAdImages($ad_id);
         //set diff. layout for single ad page
         $layout = $this->layout();
         $layout->setTemplate('layout/layout_single_ad.phtml');
         //set template for single ad page
         $viewModel->setTemplate('/ogloszenia/ogloszenia/ad.phtml');
         // path to phtml file under view folder
         $viewModel->setVariable('title', $ads_to_show->ad_title);
         //send variables to the view
         $viewModel->setVariables(array('images' => $images));
         //brand i model tu chyba nie trzeba rpzesylac
         //ads_to_show contain ads
         $viewModel->setVariable('ogloszenia', $ads_to_show);
         //print_r($ads_to_show);
         return $viewModel;
         //return false;
     }
 }
コード例 #18
0
ファイル: TabsController.php プロジェクト: LeCoyote/epeires2
 public function indexAction()
 {
     parent::indexAction();
     $viewmodel = new ViewModel();
     $return = array();
     if ($this->flashMessenger()->hasErrorMessages()) {
         $return['error'] = $this->flashMessenger()->getErrorMessages();
     }
     if ($this->flashMessenger()->hasSuccessMessages()) {
         $return['success'] = $this->flashMessenger()->getSuccessMessages();
     }
     $this->flashMessenger()->clearMessages();
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $tabid = $this->params()->fromQuery('tabid', null);
     if ($tabid) {
         $tab = $objectManager->getRepository('Application\\Entity\\Tab')->find($tabid);
         if ($tab) {
             $categories = $tab->getCategories();
             $cats = array();
             foreach ($categories as $cat) {
                 $cats[] = $cat->getId();
             }
             $viewmodel->setVariable('onlyroot', $tab->isOnlyroot());
             $viewmodel->setVariable('cats', $cats);
             $viewmodel->setVariable('tabid', $tabid);
         } else {
             $return['error'][] = "Impossible de trouver l'onglet correspondant. Contactez votre administrateur.";
         }
     } else {
         $return['error'][] = "Aucun onglet défini. Contactez votre administrateur.";
     }
     $viewmodel->setVariables(array('messages' => $return));
     return $viewmodel;
 }
コード例 #19
0
ファイル: Listing.php プロジェクト: Indigo1337/c4d
 public function singleAction()
 {
     $viewModel = new ViewModel();
     $viewModel->setTemplate('recipe/single');
     $viewModel->setVariables(['recipe' => $this->readService->findById($this->params('id'))]);
     return $viewModel;
 }
コード例 #20
0
ファイル: DemoController.php プロジェクト: sudar69/hermes
 public function testAction()
 {
     $id = $this->params()->fromRoute('id', 1);
     if (!$id) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     //$myObject = new Hgroups;
     $form = $this->getForm($this->getMyObject(), $entityManager, 'Добавить');
     $form->bind($this->getMyObject());
     $request = $this->getRequest();
     $viewmodel = new ViewModel();
     //disable layout if request by Ajax
     $viewmodel->setTerminal($request->isXmlHttpRequest());
     $is_xmlhttprequest = 1;
     if (!$request->isXmlHttpRequest()) {
         //if NOT using Ajax
         $is_xmlhttprequest = 0;
         if ($request->isPost()) {
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 //save to db <span class="wp-smiley wp-emoji wp-emoji-wink" title=";)">;)</span>
                 $this->getMyObject()->setParentid($entityManager->getReference($this->getMyEntity(), $id));
                 $entityManager->persist($this->getMyObject());
                 $entityManager->flush();
             }
         }
     }
     $viewmodel->setVariables(array('form' => $form, 'is_xmlhttprequest' => $is_xmlhttprequest));
     return $viewmodel;
 }
コード例 #21
0
ファイル: Renderer.php プロジェクト: gotcms/gotcms
 /**
  * Render template
  *
  * @param string $name Name
  * @param array  $data Data
  *
  * @return string
  */
 public function render($name, array $data = array())
 {
     $viewModel = new ViewModel();
     $viewModel->setTemplate($name);
     $viewModel->setVariables($data);
     return $this->renderer->render($viewModel);
 }
コード例 #22
0
 public function ctrlEditAction()
 {
     $view = new ViewModel();
     $view->setTemplate('application/permissions/simple-permission-guard');
     $view->setVariables(['permission' => 'edit']);
     return $view;
 }
コード例 #23
0
 public function showformAction()
 {
     $viewmodel = new ViewModel();
     $form = $this->getForm();
     $request = $this->getRequest();
     //disable layout if request by Ajax
     $viewmodel->setTerminal($request->isXmlHttpRequest());
     $is_xmlhttprequest = 1;
     if (!$request->isXmlHttpRequest()) {
         //if NOT using Ajax
         $is_xmlhttprequest = 0;
         if ($request->isPost()) {
             $form->setData($request->getPost());
             $formValidador = new ValidaFormulario();
             $form->setInputFilter($formValidador->getInputFilter());
             echo "es valido: " . "<pre>" . print_r($form->isValid(), true) . "</pre>";
             if ($form->isValid()) {
                 //save to db <span class="wp-smiley wp-emoji wp-emoji-wink" title=";)">;)</span>
                 echo "son válidos los datos";
                 //$this->savetodb($form->getData());
             }
         }
     }
     $viewmodel->setVariables(array('form' => $form, 'is_xmlhttprequest' => $is_xmlhttprequest));
     return $viewmodel;
 }
コード例 #24
0
 public function fnebrouillageAction()
 {
     $view = $this->params()->fromQuery('view', null);
     $brouillageid = $this->params()->fromQuery('id', null);
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $brouillage = $objectManager->getRepository('Application\\Entity\\Event')->find($brouillageid);
     if ($brouillage) {
         $fields = array();
         foreach ($brouillage->getCustomFieldsValues() as $values) {
             $fields[$values->getCustomField()->getId()] = $values->getValue();
         }
         $frequency = $objectManager->getRepository('Application\\Entity\\Frequency')->find($fields[$brouillage->getCategory()->getFrequencyField()->getId()]);
         if ($view == 'pdf') {
             $pdf = new PdfModel();
             $pdf->setVariable('event', $brouillage);
             $pdf->setVariables(array('frequency' => $frequency, 'fields' => $fields));
             // $pdf->setOption('filename', 'fne-brouillage');
             $pdf->setOption('paperSize', 'a4');
             return $pdf;
         } else {
             $viewmodel = new ViewModel();
             $viewmodel->setVariable('event', $brouillage);
             $viewmodel->setVariables(array('frequency' => $frequency, 'fields' => $fields));
             // disable layout if request by Ajax
             $viewmodel->setTerminal(true);
             return $viewmodel;
         }
     }
 }
コード例 #25
0
ファイル: AuthController.php プロジェクト: hopealive/ds
 public function loginAction()
 {
     $defaultRefererUrl = '/admin/index';
     if (is_object($this->_auth)) {
         $this->redirect()->toUrl($defaultRefererUrl);
     }
     $form = new \Admin\Form\AuthForm();
     $request = $this->getRequest();
     $authService = $this->getServiceLocator()->get('Zend\\Authentication\\AuthenticationService');
     $adapter = $authService->getAdapter();
     if ($request->isPost()) {
         $data = $request->getPost();
         $adapter->setIdentityValue($data['email']);
         $adapter->setCredentialValue($data['password']);
         $authResult = $authService->authenticate();
         if ($authResult->isValid()) {
             $authModel = new \Application\Model\MyAuthStorage();
             $refererUrl = $defaultRefererUrl;
             if (strlen($authModel->getReferer()) > 0) {
                 $refererUrl = $authModel->getReferer();
             }
             if (empty($refererUrl) or strpos('/auth/login', $refererUrl) > -1) {
                 $refererUrl = $defaultRefererUrl;
             }
             return $this->redirect()->toUrl($refererUrl);
         } else {
             return new ViewModel(array('form' => $form, 'error' => 'Your authentication credentials are not valid'));
         }
     }
     $viewVariables['form'] = $form;
     $view = new ViewModel();
     $view->setVariables($viewVariables);
     return $view;
 }
コード例 #26
0
ファイル: PrizeController.php プロジェクト: zhangyuxiao/qoros
 public function indexAction()
 {
     $view = new ViewModel();
     $activityId = $this->getParam('activityId', 2);
     $view->setVariables(array('activityId' => $activityId));
     return $view;
 }
コード例 #27
0
 public function deleteAction()
 {
     $viewModel = new ViewModel();
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('admin/user_type');
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $del = $request->getPost('del', 'No');
         if ($del == 'Si') {
             $id = (int) $request->getPost('id');
             $result = $this->getUserTypeTable()->delete($id);
             if (isset($result) && $result) {
                 return $this->redirect()->toRoute('admin/user_type');
             } else {
                 $viewModel->setVariable("error", true);
             }
         } else {
             return $this->redirect()->toRoute('admin/user_type');
         }
     }
     $viewModel->setVariables(array('id' => $id, 'bank' => $this->getUserTypeTable()->get($id), 'config' => $this->config));
     return $viewModel;
 }
コード例 #28
0
ファイル: Manage.php プロジェクト: Indigo1337/c4d
 private function listUsers()
 {
     $viewModel = new ViewModel();
     $viewModel->setTemplate('user/list');
     $viewModel->setVariables(['users' => $this->userService->findAll()]);
     return $viewModel;
 }
コード例 #29
0
ファイル: Mail.php プロジェクト: feijojr/EADGestao
 public function renderView($page, array $data)
 {
     $model = new ViewModel();
     $model->setTemplate("mailer/{$page}.phtml");
     $model->setOption('has_parent', true);
     $model->setVariables($data);
     return $this->view->render($model);
 }
コード例 #30
0
 /**
  * @param RenderableMailInterface $mail
  *
  * @return string
  */
 protected function renderContent(RenderableMailInterface $mail)
 {
     $viewModel = new ViewModel();
     $viewModel->setTemplate($mail->getViewFile());
     $viewModel->setTerminal(true);
     $viewModel->setVariables($mail->getParams());
     return $this->viewRenderer->render($viewModel);
 }