/** * No index action, return 404 error page * * @return \Zend\View\Model\ViewModel */ public function indexAction() { $view = new \Zend\View\Model\ViewModel(); $view->setTemplate('/error/404.phtml'); $this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_404); return $view; }
function renderInstanceFromConfig($instanceConfig) { $events = $this->calender->getEvents($instanceConfig['categoryId']); $view = new \Zend\View\Model\ViewModel(['instanceConfig' => $instanceConfig, 'events' => $events]); $view->setTemplate($this->template); return $view; }
/** * @param MvcEvent $event * * @return parent::onDispatch */ public function onDispatch(MvcEvent $event) { $request = $event->getRequest(); $remoteAddr = $request->getServer('REMOTE_ADDR'); // check IP address is allowed $application = $event->getApplication(); $config = $application->getConfig(); $autoDeployConfig = $config['auto_deploy']; $allowedIpAddresses = $autoDeployConfig['ipAddresses']; // error if ip is not allowed if (!in_array($remoteAddr, $allowedIpAddresses, true)) { $baseModel = new \Zend\View\Model\ViewModel(); $baseModel->setTemplate('layout/output'); $model = new \Zend\View\Model\ViewModel(); $model->setTemplate('error/403'); $baseModel->addChild($model); $baseModel->setTerminal(true); $event->setViewModel($baseModel); $response = $event->getResponse(); $response->setStatusCode(403); $response->sendHeaders(); $event->setResponse($response); exit; } return parent::onDispatch($event); }
/** * Return view model set up to output given form * * @param mixed $form Form to render * @return \Zend\View\Model\ViewModel */ public function __invoke($form) { $view = new \Zend\View\Model\ViewModel(); $view->setTemplate('plugin/PrintForm.php'); $view->form = $form; return $view; }
public function dispatchError(MvcEvent $e) { $sharedManager = $e->getApplication()->getEventManager()->getSharedManager(); $sharedManager->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) { if ($e->getParam('exception')) { ob_clean(); //Limpar a tela de erros do php header('HTTP/1.1 400 Bad Request'); $exception = $e->getParam('exception'); $sm = $e->getApplication()->getServiceManager(); $config = $sm->get('Config'); $e->getApplication()->getServiceManager()->get('Controller\\Plugin\\Manager')->get('jsLog')->log($exception, 2); $viewModel = new \Zend\View\Model\ViewModel(['exception' => $exception]); if ($e->getRequest()->isXmlHttpRequest()) { $viewModel->setTemplate($config['js_library']['error_ajax_exception']); $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel); } else { $viewModel->setTemplate($config['js_library']['error_exception']); echo $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel); } /* * Com erros handler o codigo continua a ser executado, * entao o exit para e so mostra os erros */ exit; } }); }
public function indexAction() { /** * @var \DDD\Service\Apartment\General $apartmentGeneralService * @var \DDD\Service\Apartment\Main $apartmentMainService * @var \DDD\Service\Apartment\OTADistribution $apartmentOTAService * @var $taskService \DDD\Service\Task * @var $bookingTicketService \DDD\Service\Booking\BookingTicket */ $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general'); $apartmentMainService = $this->getServiceLocator()->get('service_apartment_main'); $apartmentOTAService = $this->getServiceLocator()->get('service_apartment_ota_distribution'); $taskService = $this->getServiceLocator()->get('service_task'); $bookingTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket'); $apartmentTasks = $taskService->getFrontierTasksOnApartment($this->apartmentId); $apartmentOTAList = $apartmentOTAService->getOTAList($this->apartmentId); $building = $apartmentMainService->getApartmentBuilding($this->apartmentId); $apartels = $apartmentMainService->getApartmentApartels($this->apartmentId); $bookingDao = new Booking($this->getServiceLocator(), 'ArrayObject'); $mediaDao = new Media($this->getServiceLocator(), 'ArrayObject'); $dateDisabled = $currentReservation = $nextReservation = false; $apartmentDates = $apartmentMainService->getApartmentDates($this->apartmentId); $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId); if ($this->apartmentStatus == Objects::PRODUCT_STATUS_DISABLED) { $dateDisabled = $apartmentDates['disable_date']; } else { $currentReservation = $bookingDao->getCurrentReservationByAcc($this->apartmentId, date('Y-m-d')); $resId = $currentReservation['id']; $pin = $currentReservation['pin']; $current = true; if (!$currentReservation) { $nextReservation = $bookingDao->getNextReservationByAcc($this->apartmentId, date('Y-m-d')); $resId = $nextReservation['id']; $pin = $nextReservation['pin']; $current = false; } if ($resId && $pin) { $lockDatas = $bookingTicketService->getLockByReservation($resId, $pin, [LockService::USAGE_APARTMENT_TYPE]); foreach ($lockDatas as $key => $lockData) { switch ($key) { case LockService::USAGE_APARTMENT_TYPE: if ($current) { $currentReservation['pin'] = $lockData['code']; } else { $nextReservation['pin'] = $lockData['code']; } break; } } } } $img = $mediaDao->getFirstImage($this->apartmentId)['img1']; $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'currentReservation' => $currentReservation, 'nextReservation' => $nextReservation, 'dateCreated' => $apartmentDates['create_date'], 'dateDisabled' => $dateDisabled, 'img' => str_replace('orig', 445, $img), 'OTAList' => $apartmentOTAList, 'building' => $building, 'apartels' => $apartels, 'apartment' => $generalInfo, 'apartmentTasks' => $apartmentTasks]); $viewModel->setTemplate('apartment/main/index'); return $viewModel; }
/** Thêm phần view cho layout */ public function index05Action() { echo '<h3 style="color:red; font-weight:bold;">' . __METHOD__ . '</h3>'; /** get layout obj */ $layout = $this->layout(); /** gắn header vào layout */ $header = new \Zend\View\Model\ViewModel(array('headerContent' => 'asazbauxgasjbdhaxuyzas')); $header->setTemplate('mvc\\view-manager\\header'); $layout->addChild($header, 'header'); }
/** * @param HttpRequest $request * * @return \Zend\View\Model\ViewModel */ public function build(HttpRequest $request, SmartServiceResult $result, $action) { $viewModel = null; if ($request->isXmlHttpRequest()) { $viewModel = new JsonModel(); $viewModel->setTerminal(true); } else { $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setVariable('entity', $result->getEntity()); $viewModel->setVariable('form', $result->getForm()); $viewModel->setVariable('list', $result->getList()); $viewModel->setTemplate(sprintf($this->getTemplate(), $action)); } return $viewModel; }
public function checkAuth(MvcEvent $e) { /* @var $container ContainerInterface */ $container = $e->getApplication()->getServiceManager(); /* @var $navigationViewhelper \Zend\View\Helper\Navigation */ $navigationViewhelper = $container->get('ViewHelperManager')->get('navigation'); $acl = $navigationViewhelper->getAcl(); $role = $navigationViewhelper->getRole(); if (!$acl->isAllowed($role, $e->getRouteMatch()->getMatchedRouteName())) { $e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) { $e->stopPropagation(); $response = $e->getResponse(); $response->setStatusCode(403); $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setTemplate('error/403'); $e->getViewModel()->addChild($viewModel); }, 2); } }
return $this->textContent; } public function getHtmlMarkup() { if (!$this->htmlMarkup) { // View renderer $renderer = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface'); // Email content $viewContent = new \Zend\View\Model\ViewModel($this->getModel()); // The config key has the same name as the Subject Constant $viewContent->setTemplate('ckpt_signup'); // set in module.config.php $content = $renderer->render($viewContent); // Email layout $viewLayout = new \Zend\View\Model\ViewModel(array('content' => $content)); $viewLayout->setTemplate('layout_ckpt'); // set in module.config.php $htmlMarkup = $renderer->render($viewLayout); $this->htmlMarkup = $htmlMarkup; }
/** * @param \Zend\Mvc\MvcEvent $e */ public function onBootstrap(MvcEvent $e) { date_default_timezone_set('Europe/Madrid'); $sm = $e->getApplication()->getServiceManager(); $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $e->getTarget(); /* $app->getEventManager()->attach('finish', array($this, 'compressOutput'), 100); */ try { $dbInstance = $sm->get('Zend\\Db\\Adapter\\Adapter'); $dbInstance->getDriver()->getConnection()->connect(); } catch (\Exception $ex) { $viewModel = $e->getViewModel(); $viewModel->setTemplate('layout/layout'); $content = new \Zend\View\Model\ViewModel(); $content->setTemplate('error/dbconnection'); $viewModel->setVariable('content', $sm->get('ViewRenderer')->render($content)); exit($sm->get('ViewRenderer')->render($viewModel)); } }
public function indexAction() { /** * @var \DDD\Service\Apartment\Location $apartmentLocationService */ $apartmentLocationService = $this->getServiceLocator()->get('service_apartment_location'); /* @var $location \DDD\Domain\Apartment\Location\Location */ $location = $apartmentLocationService->getApartmentLocation($this->apartmentId); $preparedData = $this->prepareFormContent($location->getCountryID(), $location->getProvinceID(), $location->getBuildingID()); $preparedData['countryId'] = $location->getCountryID(); $form = new LocationForm('apartment_location', $preparedData); // Google map configuration $config = array('sensor' => 'true', 'div_id' => 'map', 'div_class' => '', 'zoom' => 10, 'width' => "", 'height' => "300px", 'lat' => $location->getX_pos(), 'lon' => $location->getY_pos()); $map = $this->getServiceLocator()->get('GMaps\\Service\\GoogleMapDragableMarker'); //getting the google map object using service manager $map->initialize($config); //loading the config $mapHTML = $map->generate(); //generating the html map content $form->populateValues(['longitude' => $location->getY_pos(), 'latitude' => $location->getX_pos(), 'location_description' => $location->getDescriptionText(), 'directions' => $location->getDirectionsText(), 'description_textline' => $location->getDescriptionTextlineID(), 'directions_textline' => $location->getDirectionsTextlineID(), 'country_id' => $location->getCountryID(), 'province_id' => $location->getProvinceID(), 'city_id' => $location->getCityID(), 'building' => $location->getBuildingID(), 'building_section' => $location->getBuildingSectionId(), 'address' => $location->getAddress(), 'postal_code' => $location->getPostalCode(), 'block' => $location->getBlock(), 'floor' => $location->getFloor(), 'unit_number' => $location->getUnitNumber()]); // set form type and template $formTemplate = 'form-templates/location'; // passing form and map to the view $viewModelForm = new \Zend\View\Model\ViewModel(); $viewModelForm->setVariables(['form' => $form, 'mapHTML' => $mapHTML, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'countryId' => $location->getCountryID(), 'building' => $location->getBuilding(), 'buildingSectionsShow' => isset($preparedData['buildingSectionOptions']) && $preparedData['buildingSectionOptions'] > 1 ? true : false]); //Country Currency List $locationService = $this->getServiceLocator()->get('service_location'); $listCountryWithCurrecny = $locationService->getCountriesWithCurrecny(); $viewModelForm->setTemplate($formTemplate); $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'listCountryWithCurrecny' => $listCountryWithCurrecny]); // child view to render form $viewModel->addChild($viewModelForm, 'formOutput'); $viewModel->setTemplate('apartment/location/index'); return $viewModel; }
/** * Attempt to change current authenticated AuthAccess email identity if available * @param string $sAuthAccessEmailIdentity * @throws \InvalidArgumentException * @return \BoilerAppAccessControl\Service\AuthAccessService */ public function changeAuthenticatedAuthAccessEmailIdentity($sAuthAccessEmailIdentity) { if (!is_string($sAuthAccessEmailIdentity)) { throw new \InvalidArgumentException('AuthAccess email identity expects string, "' . gettype($sAuthAccessEmailIdentity) . '" given'); } if (!filter_var($sAuthAccessEmailIdentity, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('AuthAccess email identity expects valid email, "' . $sAuthAccessEmailIdentity . '" given'); } $oAuthAccessRepository = $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository'); if (!$oAuthAccessRepository->isEmailIdentityAvailable($sAuthAccessEmailIdentity)) { throw new \InvalidArgumentException('AuthAccess email identity "' . $sAuthAccessEmailIdentity . '" is not available'); } //Update AuthAcces public key $oAuthAccess = $this->getServiceLocator()->get('AccessControlService')->getAuthenticatedAuthAccess(); $oAuthAccessRepository->update($oAuthAccess->setAuthAccessPublicKey($this->getServiceLocator()->get('Encryptor')->create($sPublicKey = $this->getServiceLocator()->get('AccessControlService')->generateAuthAccessPublicKey()))); //Create email view body $oView = new \Zend\View\Model\ViewModel(array('auth_access_email_identity' => $sAuthAccessEmailIdentity, 'auth_access_public_key' => $sPublicKey)); //Retrieve Messenger service $oMessengerService = $this->getServiceLocator()->get('MessengerService'); //Send email confirmation to user $oMessage = new \BoilerAppMessenger\Message\Message(); $oMessengerService->sendMessage($oMessage->setFrom($oMessengerService->getSystemUser())->setTo($oAuthAccess->getAuthAccessUser())->setSubject($this->getServiceLocator()->get('translator')->translate('confirm_change_email'))->setBody($oView->setTemplate('mail/auth-access/confirm-change-email-identity')), \BoilerAppMessenger\Media\Mail\MailMessageRenderer::MEDIA); return $this; }
/** * Set layout script * * @param \Contentinum\Options\PageOptions $pageOptions * @param Zend\View\Model\ViewModel $layout */ protected function layoutFile($pageOptions, $layout) { $layout->setTemplate($pageOptions->getLayout()); }
/** * @param string $sAuthAccessIdentity * @throws \InvalidArgumentException * @return \BoilerAppAccessControl\Service\RegistrationService */ public function resendConfirmationEmail($sAuthAccessIdentity) { if (empty($sAuthAccessIdentity) || !is_string($sAuthAccessIdentity)) { throw new \InvalidArgumentException(sprintf('AuthAccess identity expects a not empty string, "%s" given', is_scalar($sAuthAccessIdentity) ? $sAuthAccessIdentity : gettype($sAuthAccessIdentity))); } $oAccessControlService = $this->getServiceLocator()->get('AccessControlService'); if (!($oAuthAccess = $oAccessControlService->getAuthAccessFromIdentity($sAuthAccessIdentity))) { throw new \LogicException(sprintf('AuthAccess with identity "%s" does not exist', $sAuthAccessIdentity)); } //Reset public key $oAuthAccess->setAuthAccessPublicKey($this->getServiceLocator()->get('Encryptor')->create($sPublicKey = $oAccessControlService->generateAuthAccessPublicKey())); $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository')->update($oAuthAccess); //Create email view body $oView = new \Zend\View\Model\ViewModel(array('auth_access_public_key' => $sPublicKey, 'auth_access_email_identity' => $oAuthAccess->getAuthAccessEmailIdentity())); //Retrieve Messenger service $oMessengerService = $this->getServiceLocator()->get('MessengerService'); //Send email confirmation to user $oMessage = new \BoilerAppMessenger\Message\Message(); $oMessengerService->sendMessage($oMessage->setFrom($oMessengerService->getSystemUser())->setTo($oAuthAccess->getAuthAccessUser())->setSubject($this->getServiceLocator()->get('translator')->translate('register'))->setBody($oView->setTemplate('mail/registration/confirm-email')), \BoilerAppMessenger\Media\Mail\MailMessageRenderer::MEDIA); return $this; }
<?php require "./vendor/autoload.php"; $vm = new \Zend\View\Model\ViewModel(array('nom' => 'tintin', 'title' => 'tintin', 'description' => 'bande dessinée', 'link' => 'http://manewa.fr')); $vm->setTemplate('testTintin'); $resolv = new \Zend\View\Resolver\TemplateMapResolver(array('testTintin' => __DIR__ . '/tintin.phtml')); $rendu = new \Zend\View\Renderer\JsonRenderer(); $rendu->setResolver($resolv); echo $rendu->render($vm);
<?php require_once './autoloader.php'; use Zend\Mail\Message; use Zend\Mail\Transport; use Zend\Di\Di; use Zend\Di\Config as DiConfig; $diConfig = array('instance' => array('Zend\\Mail\\Transport\\FileOptions' => array('parameters' => array('path' => __DIR__)), 'Zend\\Mail\\Transport\\File' => array('injections' => array('Zend\\Mail\\Transport\\FileOptions')), 'Zend\\Mail\\Transport\\SmtpOptions' => array('parameters' => array('name' => 'sendgrid', 'host' => 'smtp.sendgrid.net', 'port' => 25, 'connectionClass' => 'login', 'connectionConfig' => array('username' => '*****@*****.**', 'password' => 'password'))), 'Zend\\Mail\\Message' => array('parameters' => array('headers' => 'Zend\\Mail\\Headers', 'Zend\\Mail\\Message::setTo:emailOrAddressList' => '*****@*****.**', 'Zend\\Mail\\Message::setTo:name' => 'EvaEngine', 'Zend\\Mail\\Message::setFrom:emailOrAddressList' => '*****@*****.**', 'Zend\\Mail\\Message::setFrom:name' => 'EvaEngine', 'setBody' => 'Zend\\View\\Renderer\\PhpRenderer::render')), 'Zend\\Mail\\Transport\\Smtp' => array('injections' => array('Zend\\Mail\\Transport\\SmtpOptions')))); $di = new Di(); $di->configure(new DiConfig($diConfig)); $transport = $di->get('Zend\\Mail\\Transport\\Smtp'); $transport = $di->get('Zend\\Mail\\Transport\\Sendmail'); $transport = $di->get('Zend\\Mail\\Transport\\File'); $message = $di->get('Zend\\Mail\\Message'); $view = new Zend\View\Renderer\PhpRenderer(); $resolver = new Zend\View\Resolver\TemplatePathStack(); $resolver->setPaths(array('mailTemplate' => __DIR__)); $view->setResolver($resolver); $viewModel = new Zend\View\Model\ViewModel(); $viewModel->setTemplate('mail/template')->setVariables(array('user' => 'AlloVince')); $message->setSubject("Zend Mail with Template")->setBody($view->render($viewModel)); $transport->send($message);
public function indexAction() { /** @var \DDD\Service\Apartment\Details $apartmentDetailsService */ $apartmentDetailsService = $this->getServiceLocator()->get('service_apartment_details'); /** @var \DDD\Service\Apartment\Furniture $apartmentFurnitureService */ $apartmentFurnitureService = $this->getServiceLocator()->get('service_apartment_furniture'); /** @var \DDD\Service\Apartment\General $apartmentGeneralService */ $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general'); /** @var \DDD\Service\Apartment\Amenities $apartmentAmenitiesService */ $apartmentAmenitiesService = $this->getServiceLocator()->get('service_apartment_amenities'); /** @var \DDD\Service\Apartment\AmenityItems $apartmentAmenityItemsService */ $apartmentAmenityItemsService = $this->getServiceLocator()->get('service_apartment_amenity_items'); /** @var \DDD\Service\Parking\General $parkingGeneralService */ $parkingGeneralService = $this->getServiceLocator()->get('service_parking_general'); /** @var \DDD\Service\Parking\Spot $parkingSpotService */ $parkingSpotService = $this->getServiceLocator()->get('service_parking_spot'); /** @var \DDD\Dao\Accommodation\Accommodations $accDao */ $accDao = $this->getServiceLocator()->get('dao_accommodation_accommodations'); /** @var \DDD\Dao\Textline\Apartment $texlineApartmentDao */ $texlineApartmentDao = $this->getServiceLocator()->get('dao_textline_apartment'); /** @var \DDD\Dao\Apartment\Spots $apartmentSpotsDao */ $apartmentSpotsDao = $this->getServiceLocator()->get('dao_apartment_spots'); $formOptions = []; $details = $apartmentDetailsService->getApartmentDetails($this->apartmentId); $furnitureList = $apartmentFurnitureService->getApartmentFurnitureList($this->apartmentId); $furnitureTypes = $apartmentFurnitureService->getFurnitureTypes(); $roomId = $apartmentGeneralService->getRoomID($this->apartmentId); $generalDetails = $apartmentGeneralService->getInfoForDetailsController($this->apartmentId); $lockId = $generalDetails['lock_id']; $formOptions['parkingLots'] = $parkingGeneralService->getParkingLotsForSelect($this->apartmentId); $apartmentAmenities = $apartmentAmenityItemsService->getApartmentAmenities($this->apartmentId); $amenitiesList = $apartmentAmenitiesService->getAmenitiesList(); $accInfo = $accDao->getAccById($this->apartmentId); $accCurrency = $accInfo->getCurrencyCode(); $facilities = $apartmentGeneralService->getBuildingFacilitiesByApartmentId($this->apartmentId); $moneyAccountId = isset($details['money_account_id']) ? $details['money_account_id'] : null; $lockApartmentUsageService = $this->getServiceLocator()->get('service_lock_usages_apartment'); $formOptions['freeLocks'] = $lockApartmentUsageService->getLockByUsage($this->apartmentId); $bankAccountDao = new \DDD\Dao\MoneyAccount\MoneyAccount($this->getServiceLocator()); $formOptions['bankAccounts'] = $bankAccountDao->getMoneyAccountOptions($moneyAccountId); $lotId = $accInfo->getLotId(); $parkingLotData = $parkingGeneralService->getParkingById($lotId); $spots = $parkingSpotService->getSpotsByBuilding($accInfo->getBuildingId()); $formOptions['parkingSpots'] = ['' => '-- Choose Parking Spot --']; if ($spots->count()) { foreach ($spots as $spot) { $formOptions['parkingSpots'][$spot->getId()] = $spot->getLotName() . ': ' . $spot->getUnit(); } } $apartmentSpots = $apartmentSpotsDao->getApartmentSpots($this->apartmentId); $apartmentParkingSpots = []; if ($apartmentSpots->count()) { foreach ($apartmentSpots as $apartmentSpot) { array_push($apartmentParkingSpots, $apartmentSpot['spot_id']); } } $form = new DetailsForm('apartment_details', $formOptions); $form->prepare(); $details['lock_id'] = $lockId; $form->populateValues($details); // set form type and template $formTemplate = 'form-templates/details'; $router = $this->getEvent()->getRouter(); $editKiDirectTypeTextlineLink = $router->assemble(['controller' => 'translation', 'action' => 'editkidirectentry', 'id' => $this->apartmentId], ['name' => 'backoffice/default']); // get apartment usage information $apartmentUsage = $texlineApartmentDao->getApartmentUsageByApartmentId($this->apartmentId); // get building usage information $apartmentBuildingUsage = $texlineApartmentDao->getApartmentBuildingUsageByApartmentId($this->apartmentId); // get building facilities information $apartmentBuildingFacility = $texlineApartmentDao->getApartmentBuildingFacilityByApartmentId($this->apartmentId); // get building policy information $apartmentBuildingPolicy = $texlineApartmentDao->getApartmentBuildingPolicyByApartmentId($this->apartmentId); $buildingDirectEntryTextline = $texlineApartmentDao->getBuildingDirectEntryTextline($this->apartmentId); // passing form and map to the view $viewModelForm = new \Zend\View\Model\ViewModel(); $viewModelForm->setVariables(['form' => $form, 'apartmentUsage' => $apartmentUsage, 'apartmentBuildingUsage' => $apartmentBuildingUsage, 'apartmentBuildingFacility' => $apartmentBuildingFacility, 'apartmentBuildingPolicy' => $apartmentBuildingPolicy, 'buildingDirectEntryTextline' => $buildingDirectEntryTextline, 'editKiDirectEntryTypeLink' => $editKiDirectTypeTextlineLink, 'furnitureList' => $furnitureList, 'amenitiesList' => $amenitiesList, 'apartmentAmenities' => $apartmentAmenities, 'furnitureTypes' => $furnitureTypes, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'roomId' => $roomId, 'accCurrency' => $accCurrency, 'facilities' => $facilities]); $viewModelForm->setTemplate($formTemplate); $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'apartmentParkingSpots' => $apartmentParkingSpots, 'parkingLotIsVirtualStatus' => $parkingLotData ? $parkingLotData->isVirtual() : false]); // child view to render form $viewModel->addChild($viewModelForm, 'formOutput'); $viewModel->setTemplate('apartment/details/index'); return $viewModel; }
/** * @param string $type * @return string */ function generateTemplate($type = 'html') { $entity = $this->getEntity(); $config = $this->getConfig(); $view = new \Zend\View\Renderer\PhpRenderer(); $view->setResolver($this->pathStack); if (strlen($entity->getTemplate()) > 0) { $templatePath = 'email/'; if (strpos($entity->getTemplate(), '/') === false) { $templatePath .= $entity->getTemplate(); } else { $templatePath = $entity->getTemplate(); } } else { $templatePath = 'email/default'; } if ($type == 'html') { $content = $entity->getHtml(); } else { $content = $entity->getText(); } $viewModel = new \Zend\View\Model\ViewModel(array_merge(array('content' => $content), $entity->getVars())); $viewModel->setTemplate($templatePath); $layout = new \Zend\View\Model\ViewModel(array('content' => $view->render($viewModel), 'site_name' => $config['site_name'])); $layout->setTerminal(true); $layout->setTemplate('layout/' . $type); return $view->render($layout); }
/** * Rendering params wrap to ajax communication * * @return string */ public function renderParamsWrap() { $view = new \Zend\View\Model\ViewModel(); $view->setTemplate('default-params'); $view->setVariable('column', $this->getTable()->getParamAdapter()->getColumn()); $view->setVariable('itemCountPerPage', $this->getTable()->getParamAdapter()->getItemCountPerPage()); $view->setVariable('order', $this->getTable()->getParamAdapter()->getOrder()); $view->setVariable('page', $this->getTable()->getParamAdapter()->getPage()); $view->setVariable('quickSearch', $this->getTable()->getParamAdapter()->getQuickSearch()); $view->setVariable('rowAction', $this->getTable()->getOptions()->getRowAction()); return $this->getRenderer()->render($view); }
public function editAction() { $currentUser = $this->getServiceLocator()->get('OrgHeiglHybridAuthToken'); if (!$currentUser->isAuthenticated()) { throw new UnauthenticatedException('You have to be logged in to edit the informations for this usergroup.', 0, null, 'You are not logged in'); } $acl = $this->getServiceLocator()->get('acl'); if (!$acl) { $this->getResponse()->setStatusCode(500); return array('error' => array('title' => 'Something went wrong on our side', 'message' => 'We apologize for the inconvenience, but someone seems to have misconfigured the Access Control System')); } $id = $this->getEvent()->getRouteMatch()->getParam('id'); $objectManager = $this->getEntityManager(); $usergroup = $objectManager->getRepository('Phpug\\Entity\\Usergroup')->findBy(array('shortname' => $id)); if (!$usergroup) { $this->getResponse()->setStatusCode(404); return array('error' => array('title' => 'No Usergroup found', 'message' => 'We could not find the usergroup you requested!</p><p>Perhaps the usergroup has been renamed or there is a typo in its name? Please check back with the contac ts of the usergroup or feel free to contact us via the <a href="/contact">Contact-Form</a>!')); } $usergroup = $usergroup[0]; /** @var \Phpug\Entity\Usergroup $usergroup */ if (!$usergroup->hasContacts()) { $contact = new Groupcontact(); $contact->group = $usergroup; $usergroup->addContact($contact); } $role = $this->getServiceLocator()->get('roleManager')->setUserToken($currentUser); $this->getServiceLocator()->get('usersGroupAssertion')->setUser($currentUser)->setGroup($usergroup); if (!$acl->isAllowed((string) $role, 'ug', 'edit')) { $this->getResponse()->setStatusCode(403); throw new UnauthorizedException('Your account has not the necessary rights to edit this usergroup. If you feel like that is an error please contact one of the representatives of the usergroup. If that doesn\'t help (Or you have locked yourself out) feel free to contact us via the <a href="/contact">Contact-Form</a>!', 0, null, 'You are not authorized to do that'); } $form = $this->getServiceLocator()->get('PromoteUsergroupForm'); $form->bind($usergroup); $form->setAttribute('action', $this->url()->fromRoute('ug/edit', array('id' => $id))); $form->get('userGroupFieldset')->get('location')->setValue($usergroup->getLocation()); if (!$acl->isAllowed((string) $role, 'ug', 'validate')) { $form->get('userGroupFieldset')->remove('state'); } $request = $this->getRequest(); if ($request->isPost()) { // Handle form sending $form->setData($request->getPost()); if ($form->isValid()) { // Handle storage of form data try { // Store content $objectManager->persist($form->getData()); $objectManager->flush(); } catch (Exception $e) { error_log($e->getMessage()); } $this->flashMessenger()->addSuccessMessage(sprintf('Your Entry has been stored and you should already see the changes you did for %1$s.', $usergroup->getName())); return $this->redirect()->toRoute('home'); } else { } } $view = new \Zend\View\Model\ViewModel(array('form' => $form)); $view->setTemplate('phpug/usergroup/promote.phtml'); return $view; }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ require './vendor/autoload.php'; $vm = new \Zend\View\Model\ViewModel(); $vm->setVariables(array('nom' => 'tintin')); $vm->setTemplate('liste'); $rendu = new \Zend\View\Renderer\PhpRenderer(); echo $rendu->render($vm);
/** * @param string $sResetKey * @throws \Exception * @return \BoilerAppAccessControl\Service\AuthenticationService */ public function resetCredential($sPublicKey, $sEmailIdentity) { if (empty($sPublicKey) || !is_string($sPublicKey)) { throw new \InvalidArgumentException('Public key expects a not empty string , "' . gettype($sPublicKey) . '" given'); } if (empty($sEmailIdentity) || !is_string($sEmailIdentity)) { throw new \InvalidArgumentException('Email identity expects a not empty string , "' . gettype($sEmailIdentity) . '" given'); } if (!($oAuthAccess = $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository')->findOneBy(array('auth_access_email_identity' => $sEmailIdentity)))) { throw new \LogicException('AuthAccess with email identity "' . $sEmailIdentity . '" does not exist'); } //Verify public key $oEncryptor = $this->getServiceLocator()->get('Encryptor'); if (!$oEncryptor->verify($sPublicKey, $oAuthAccess->getAuthAccessPublicKey())) { throw new \LogicException(sprintf('Public key "%s" is not valid for email identity "%s"', $sPublicKey, $sEmailIdentity)); } elseif ($oAuthAccess->getAuthAccessState() !== \BoilerAppAccessControl\Repository\AuthAccessRepository::AUTH_ACCESS_ACTIVE_STATE) { throw new \LogicException(sprintf('AuthAccess "%s" is not active', $oAuthAccess->getAuthAccessId())); } //Update AuthAccess entity $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository')->update($oAuthAccess->setAuthAccessCredential($oEncryptor->create(md5($sCredential = md5(date('Y-m-d') . str_shuffle(uniqid())))))->setAuthAccessPublicKey($oEncryptor->create($this->getServiceLocator()->get('AccessControlService')->generateAuthAccessPublicKey()))); //Create email view body $oView = new \Zend\View\Model\ViewModel(array('auth_access_username_identity' => $oAuthAccess->getAuthAccessUsernameIdentity(), 'auth_access_credential' => $sCredential)); //Retrieve Messenger service $oMessengerService = $this->getServiceLocator()->get('MessengerService'); $oMessage = new \BoilerAppMessenger\Message\Message(); $oMessengerService->sendMessage($oMessage->setFrom($oMessengerService->getSystemUser())->setTo($oAuthAccess->getAuthAccessUser())->setSubject($this->getServiceLocator()->get('translator')->translate('reset_credential'))->setBody($oView->setTemplate('mail/authentication/credential-reset')), \BoilerAppMessenger\Media\Mail\MailMessageRenderer::MEDIA); return $this; }