Ejemplo n.º 1
12
 public function PdfAction()
 {
     $pdf = new TCPDF('L');
     $pdf->SetPrintHeader(true);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
         require_once dirname(__FILE__) . '/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // set font
     $pdf->SetFont('helvetica', '', 8);
     // add a page
     $pdf->AddPage();
     //get report data into $data variable
     $project = $this->getServiceLocator()->get('ProjectTable');
     $data = $project->getWsr();
     $view = new PhpRenderer();
     $resolver = new TemplateMapResolver();
     //set the path of the pdf.phtml file
     $resolver->setMap(array('PDFTemplate' => '/var/www/html/WSRAutomation/module/Application/view/application/index/pdf.phtml'));
     $view->setResolver($resolver);
     $viewModel = new ViewModel();
     $viewModel->setTemplate('PDFTemplate')->setVariables(array('projects' => $data, 'view' => 'pdf'));
     $html = $view->render($viewModel);
     $pdf->writeHTML($html, true, 0, true, 0);
     $pdf->Output('WsrReport.pdf', 'I');
 }
 public function onRoute(MvcEvent $e)
 {
     $request = $e->getRequest();
     if (!$request instanceof HttpRequest) {
         return;
     }
     $application = $e->getApplication();
     $serviceLocator = $application->getServiceManager();
     // Load the configuration for maintenance mode
     if ($serviceLocator->has('MaintenanceConfig')) {
         $config = $serviceLocator->get('MaintenanceConfig');
     } else {
         $config = new Config();
     }
     if (!$config->isEnabled()) {
         // Maintenance mode is disabled.
         return;
     }
     // Check the white list
     if ($request instanceof PhpRequest) {
         $address = $request->getServer('REMOTE_ADDR', null);
     } else {
         $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
     }
     if (!empty($address)) {
         if (in_array($address, $config->getWhitelist())) {
             return;
         }
     }
     // Render the maintenance layout
     $renderer = new PhpRenderer();
     if ($serviceLocator->has('ViewHelperManager')) {
         $renderer->setHelperPluginManager($serviceLocator->get('ViewHelperManager'));
     }
     $resolver = new TemplateMapResolver();
     $resolver->add('maintenance', $config->getTemplate());
     $renderer->setResolver($resolver);
     $content = $renderer->render('maintenance');
     // Set the response
     $response = $e->getResponse();
     if (!$response instanceof HttpResponse) {
         $response = new HttpResponse();
     }
     $statusCode = $config->getStatusCode();
     $response->setStatusCode($statusCode);
     if ($statusCode === 503 && !$response->getHeaders()->has('Retry-After')) {
         $retryDate = $config->getRetryAfter();
         if ($retryDate instanceof DateTime) {
             $retryAfter = new RetryAfter();
             $retryAfter->setDate($retryDate);
             $response->getHeaders()->addHeader($retryAfter);
         }
     }
     $response->setContent($content);
     $e->setResponse($response);
     // Return the response
     return $response;
 }
Ejemplo n.º 3
0
 public function testFromRenderWithCheckbox()
 {
     $formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['terms' => ['template' => 't4web-form-renderer/element/checkbox', 'variables' => ['label' => 'Terms']]], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
     $factory = new Factory();
     $form = $factory->create($formConfig);
     $form->setData(['terms' => 1]);
     $form->setMessages(['terms' => ["You must read and check"]]);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create">
                 <div class="box-body">
                     <div class="form-group has-error">
                         <div class="checkbox">
                             <label>
                                 <input type="checkbox" name="terms" value="1"> Terms
                             </label>
                         </div>
                         <p class="help-block">You must read and check</p>
                     </div>
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
Ejemplo n.º 4
0
 /**
  * @param Message $message
  * @return Message
  */
 public function render(Message $message)
 {
     $viewModel = new ViewModel($this->variables);
     $viewModel->setTemplate($this->template);
     $helperPluginManager = $this->renderer->getHelperPluginManager();
     /** @var HeadTitle $helper */
     $helper = $helperPluginManager->get('HeadTitle');
     // replace headTitle
     $headTitle = new HeadTitle();
     $headTitle->setAutoEscape(false);
     $helperPluginManager->setAllowOverride(true);
     $helperPluginManager->setService('HeadTitle', $headTitle);
     if (!$message->getBody()) {
         $message->setBody(new MimeMessage());
     }
     $text = new Part($this->renderer->render($viewModel));
     $text->charset = 'UTF-8';
     $text->boundary = $message->getBody()->getMime()->boundary();
     $text->encoding = Mime::ENCODING_BASE64;
     $text->type = Mime::TYPE_HTML;
     $message->getBody()->addPart($text);
     $message->setSubject($headTitle->renderTitle());
     // hack for ZF
     $message->setBody($message->getBody());
     // restore original helper
     $helperPluginManager->setService('HeadTitle', $helper);
     return $message;
 }
Ejemplo n.º 5
0
 /**
  * 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);
 }
Ejemplo n.º 6
0
 public function testFromRenderWithPassword()
 {
     $formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['status' => ['template' => 't4web-form-renderer/element/select', 'variables' => ['labels' => [1 => 'Active', 2 => 'In active', 3 => 'Deleted']]]], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
     $factory = new Factory();
     $form = $factory->create($formConfig);
     $form->setData(['status' => 3]);
     $form->setMessages(['status' => ["This field is required"]]);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create">
                 <div class="box-body">
                     <div class="form-group has-error">
                         <label>Select</label>
                         <select name="status" class="form-control">
                             <option value="1" >Active</option>
                             <option value="2" >In active</option>
                             <option value="3" selected>Deleted</option>
                         </select>
                         <p class="help-block">This field is required</p>
                     </div>
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
Ejemplo n.º 7
0
 public function render($variables, $template)
 {
     $this->phpRenderer->setVars($variables);
     $result = $this->phpRenderer->render($template);
     $this->phpRenderer->setVars(array());
     return $result;
 }
Ejemplo n.º 8
0
 public function showAction()
 {
     $this->composerInfo->parse();
     $loadedModules = $this->moduleManager->getLoadedModules();
     $packages = $this->composerInfo->getPackages();
     $this->viewModel->setPackages($packages);
     $this->viewModel->setLoadedModules($loadedModules);
     $this->viewModel->setTemplate('list-show');
     return $this->renderer->render($this->viewModel);
 }
Ejemplo n.º 9
0
 public function renderError(MvcEvent $e)
 {
     $error = $e->getError();
     $app = $e->getTarget();
     $response = $e->getResponse();
     if (!$response) {
         $response = new Response();
         $e->setResponse($response);
     }
     if ($response->getStatusCode() == 404) {
         $error = $response->getStatusCode();
     }
     if (!empty($error)) {
         switch ($error) {
             case Application::ERROR_CONTROLLER_NOT_FOUND:
             case Application::ERROR_CONTROLLER_INVALID:
                 $vars = array('message' => 'Page not found.');
                 $response->setStatusCode(404);
                 break;
             case Application::ERROR_EXCEPTION:
             default:
                 $exception = $e->getParam('exception');
                 $vars = array('message' => 'An error occurred during execution, please try again later.', 'exception' => $e->getParam('exception'), 'display_exceptions' => $this->displayExceptions());
                 $response->setStatusCode(500);
                 break;
         }
         $content = $this->view->render('error/index.phtml', $vars);
         $e->setResult($content);
         return $this->renderLayout($e);
     }
     return '';
 }
Ejemplo n.º 10
0
 /**
  * Build Message
  *
  * @return MailMessage
  */
 public function buildMessage()
 {
     // prepare html body
     $htmlBody = $this->renderer->render($this->viewModel);
     // prepare text body
     $textBody = $this->buildTextBody($htmlBody);
     // prepare subject
     $subject = $this->buildSubject($htmlBody);
     // prepare html part
     $htmlPart = new MimePart($this->buildHtmlHeader() . $htmlBody . $this->buildHtmlFooter());
     $htmlPart->type = 'text/html';
     // prepare text part
     $textPart = new MimePart($textBody);
     $textPart->type = 'text/plain';
     // prepare mime message
     $mailBody = new MimeMessage();
     $mailBody->setParts(array($textPart, $htmlPart));
     // prepare message
     $this->message = new MailMessage();
     $this->message->setEncoding($this->encoding);
     $this->message->setFrom($this->senderMail, $this->senderName);
     $this->message->setSubject($subject);
     $this->message->setBody($mailBody);
     // return mailer
     return $this;
 }
Ejemplo n.º 11
0
 public function testFromRenderWithHidden()
 {
     $formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['id' => ['template' => 't4web-form-renderer/element/hidden']], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
     $factory = new Factory();
     $form = $factory->create($formConfig);
     $form->setData(['id' => 123]);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create">
                 <div class="box-body">
                     <input type="hidden" name="id" class="form-control" value="123">
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
Ejemplo n.º 12
0
 public function autocompleteAction(Request $request, Response $response = null)
 {
     $serviceManager = $this->getServiceLocator();
     $console = $serviceManager->get('console');
     $resolver = $serviceManager->get('ViewResolver');
     $render = new PhpRenderer();
     $render->setResolver($resolver);
     $console->write($render->render('client/manual/autocomplete'));
 }
Ejemplo n.º 13
0
 protected function renderTemplatePath($strPath, $arrVariables)
 {
     $view = new PhpRenderer();
     $resolver = new TemplateMapResolver();
     $resolver->setMap(array('mailTemplate' => __DIR__ . '/../../../' . $strPath));
     $view->setResolver($resolver);
     $viewModel = new ViewModel();
     $viewModel->setTemplate('mailTemplate')->setVariables($arrVariables);
     return $view->render($viewModel);
 }
Ejemplo n.º 14
0
 public function render()
 {
     $renderer = new PhpRenderer();
     $resolver = new Resolver\AggregateResolver();
     $renderer->setResolver($resolver);
     $map = new Resolver\TemplateMapResolver(array(static::getTemplate() => __DIR__ . '/view/' . static::getTemplate() . '.phtml'));
     $resolver->attach($map);
     // this will be consulted first
     return $renderer->render($this);
 }
Ejemplo n.º 15
0
 public function getContent()
 {
     $info = new \SplFileInfo($this->file);
     $renderer = new PhpRenderer();
     $stack = new TemplatePathStack();
     $stack->addPath($info->getPath());
     $stack->setDefaultSuffix(pathinfo($this->file, PATHINFO_EXTENSION));
     $renderer->setResolver($stack);
     return $renderer->render($info->getBasename());
 }
Ejemplo n.º 16
0
 public function testFromRenderWithFile()
 {
     $formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['file' => ['template' => 't4web-form-renderer/element/file', 'variables' => ['label' => 'File']]], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
     $factory = new Factory();
     $form = $factory->create($formConfig);
     $form->setMessages(['file' => ["This field is required"]]);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create">
                 <div class="box-body">
                     <div class="form-group has-error">
                         <label class="control-label">File</label>
                         <input type="file" name="file" class="form-control">
                         <p class="help-block">This field is required</p>
                     </div>
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
Ejemplo n.º 17
0
 /**
  * Convenience method to send the emails
  *
  * @param string $toAddress 
  * @param string $toName 
  * @param string $subject 
  * @param string $body 
  * @return void
  */
 protected static function send($toAddress, $toName, $subject, $templateName, $templateVars = array())
 {
     $view = new PhpRenderer();
     $view->setResolver(self::initResolver());
     $viewModel = new ViewModel();
     $viewModel->setTemplate($templateName)->setVariables($templateVars);
     $content = $view->render($viewModel);
     $viewLayout = new ViewModel();
     $viewLayout->setTemplate('MailLayout')->setVariables(array('content' => $content));
     $html = new MimePart($view->render($viewLayout));
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $mail = new Message();
     $mail->setBody($body);
     $mail->setFrom('*****@*****.**', 'My social network');
     $mail->addTo($toAddress, $toName);
     $mail->setSubject($subject);
     $transport = new Sendmail();
     $transport->send($mail);
 }
Ejemplo n.º 18
0
 /**
  * Get a plugin instance rendered view.
  *
  * @param string  $pluginName           Plugin name
  * @param integer $pluginInstanceId     Plugin Instance Id
  * @param array   $pluginInstanceConfig Plugin Instance Config
  *
  * @return array
  * @throws \Rcm\Exception\InvalidPluginException
  * @throws \Rcm\Exception\PluginReturnedResponseException
  */
 public function getPluginViewData($pluginName, $pluginInstanceId, $pluginInstanceConfig)
 {
     /** @var \Rcm\Plugin\PluginInterface $controller */
     $controller = $this->getPluginController($pluginName);
     if (!is_a($controller, '\\Rcm\\Plugin\\PluginInterface')) {
         throw new InvalidPluginException('Plugin ' . $controller . ' must implement the PluginInterface');
     }
     $controller->setRequest($this->request);
     $response = new Response();
     $controller->setResponse($response);
     /** @var \Zend\Mvc\MvcEvent $event */
     $event = $controller->getEvent();
     $event->setRequest($this->request);
     $event->setResponse($response);
     $controller->setEvent($event);
     $viewModel = $controller->renderInstance($pluginInstanceId, $pluginInstanceConfig);
     if ($viewModel instanceof ResponseInterface) {
         $event = new ViewEvent();
         $event->setResponse($viewModel);
         $this->eventManager->trigger(ViewEvent::EVENT_RESPONSE, $event);
         return null;
     }
     /** @var \Zend\View\Helper\Headlink $headlink */
     $headlink = $this->renderer->plugin('headlink');
     /** @var \Zend\View\Helper\HeadScript $headScript */
     $headScript = $this->renderer->plugin('headscript');
     $oldContainer = $headlink->getContainer();
     $linkContainer = new Container();
     $headlink->setContainer($linkContainer);
     $oldScriptContainer = $headScript->getContainer();
     $headScriptContainer = new Container();
     $headScript->setContainer($headScriptContainer);
     $html = $this->renderer->render($viewModel);
     $css = $headlink->getContainer()->getArrayCopy();
     $script = $headScript->getContainer()->getArrayCopy();
     $return = ['html' => $html, 'css' => $this->getContainerSrc($css), 'js' => $this->getContainerSrc($script), 'editJs' => '', 'editCss' => '', 'displayName' => '', 'tooltip' => '', 'icon' => '', 'siteWide' => false, 'md5' => '', 'fromCache' => false, 'canCache' => false, 'pluginName' => $pluginName, 'pluginInstanceId' => $pluginInstanceId];
     if (isset($this->config['rcmPlugin'][$pluginName]['display'])) {
         $return['displayName'] = $this->config['rcmPlugin'][$pluginName]['display'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['tooltip'])) {
         $return['tooltip'] = $this->config['rcmPlugin'][$pluginName]['tooltip'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['icon'])) {
         $return['icon'] = $this->config['rcmPlugin'][$pluginName]['icon'];
     }
     if (isset($this->config['rcmPlugin'][$pluginName]['canCache'])) {
         $return['canCache'] = $this->config['rcmPlugin'][$pluginName]['canCache'];
     }
     $headlink->setContainer($oldContainer);
     $headScript->setContainer($oldScriptContainer);
     return $return;
 }
Ejemplo n.º 19
0
 public function testFromRenderWithPassword()
 {
     $formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['options' => ['template' => 't4web-form-renderer/element/radio', 'variables' => ['labels' => [1 => 'Option one', 2 => 'Option two', 3 => 'Option three']]]], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
     $factory = new Factory();
     $form = $factory->create($formConfig);
     $form->setData(['options' => 2]);
     $form->setMessages(['options' => ["This field is required"]]);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create">
                 <div class="box-body">
                     <div class="form-group has-error">
                         <div class="radio">
                             <label>
                                 <input type="radio" name="options" value="1" >
                                 Option one
                             </label>
                         </div>
                         <div class="radio">
                             <label>
                                 <input type="radio" name="options" value="2" checked="">
                                 Option two
                             </label>
                         </div>
                         <div class="radio">
                             <label>
                                 <input type="radio" name="options" value="3" >
                                 Option three
                             </label>
                         </div>
                         <p class="help-block">This field is required</p>
                     </div>
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
Ejemplo n.º 20
0
 public function render($nameOrModel, $values = null)
 {
     $template = $nameOrModel;
     $disable = false;
     if ($nameOrModel instanceof Model) {
         $template = $nameOrModel->getTemplate();
         $disable = $nameOrModel->getVariable('__disableTemplateDebugger', false);
     }
     $output = parent::render($nameOrModel, $values);
     if ($disable) {
         return $output;
     }
     return '<!-- template-identity: ' . $template . ' -->' . $output;
     // filter output
 }
Ejemplo n.º 21
0
 /**
  * {@inheritdoc}
  */
 public function render($nameOrModel, $values = null)
 {
     $results = $this->getEventManager()->trigger(__FUNCTION__ . '.pre', $this, ['block' => $nameOrModel], function ($result) {
         return is_string($result);
     });
     if ($results->stopped()) {
         return $results->last();
     } else {
         if ($nameOrModel instanceof ModelInterface && $nameOrModel->hasChildren() && $this->canRenderTrees()) {
             $this->renderChildren($nameOrModel);
         }
         $rendered = parent::render($nameOrModel, $values);
     }
     $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, ['__RESULT__' => $rendered]);
     return $rendered;
 }
Ejemplo n.º 22
0
 private function createFile($model, $params = [])
 {
     $renderer = new PhpRenderer();
     $stack = new Resolver\TemplatePathStack(array('script_paths' => $this->getServiceLocator()->get('config')['gzfextra_console_create']));
     $renderer->setResolver($stack);
     $view = new ViewModel(['module' => $this->module, 'name' => $this->name, 'table' => $this->table, 'entity' => $this->params('re') ? '\\' . RowGateway::class : ($this->params('e') ? $this->name : '\\ArrayObject')] + $params);
     $view->setTemplate("gzfextra/console/create-{$model}");
     $content = $renderer->render($view);
     $path = "module/{$this->module}/src/{$this->module}/Model/{$this->name}" . ($model == 'table' ? "Table" : "") . ".php";
     if (file_exists($path)) {
         copy($path, $path . '.' . date('mdHis'));
     }
     $this->mkdirs(dirname($path));
     is_dir(dirname($path)) && file_put_contents($path, $content);
     echo "Create file: {$path}\n";
 }
Ejemplo n.º 23
0
 public function setMensagem($conteudo, $dados = null)
 {
     //Se o conteudo correspode a um template html
     if (file_exists($conteudo)) {
         echo 'oiii';
         $viewModel = new ViewModel();
         $viewModel->setTemplate($conteudo)->setTerminal(TRUE)->setOption('has_parent', true)->setVariable('dados', $dados);
         $render = new PhpRenderer();
         var_dump($render->render($viewModel));
         die;
     }
     $html = new MimePart($conteudo);
     $html->type = 'text/html';
     $body = new MimeMessage();
     $body->setParts([$html]);
     $this->objMessage->setBody($body);
     return $this;
 }
Ejemplo n.º 24
0
 /**
  * 
  * @param string|ViewModel $nameOrModel
  * @param mixed $values
  * @return string
  * @throws DomainException
  */
 public function renderStrategyZend($nameOrModel, $values = null)
 {
     $model = null;
     if ($nameOrModel instanceof ModelInterface) {
         $model = $nameOrModel;
         $nameOrModel = $model->getTemplate();
         if (empty($nameOrModel)) {
             throw new DomainException(sprintf('%s: received View Model argument, but template is empty', __METHOD__));
         }
         $values = (array) $model->getVariables();
     }
     if (!$this->canRender($nameOrModel)) {
         return null;
     }
     if ($model && $this->canRenderTrees() && $model->hasChildren()) {
         if (!isset($values['content'])) {
             $values['content'] = '';
         }
         foreach ($model as $child) {
             $isTwigTemplate = false;
             try {
                 $path = $this->loader->getCacheKey($child->getTemplate());
                 $isTwigTemplate = substr($path, -5) == '.twig';
             } catch (\Exception $e) {
             }
             /** @var ViewModel $child */
             if ($isTwigTemplate) {
                 /* @var $template Twig_TemplateInterface */
                 $path = $child->getTemplate();
                 $template = $this->resolver->resolve($path, $this);
                 $values[$child->captureTo()] = $template->render((array) $child->getVariables());
                 $this->getEventManager()->triggerEvent(new LogEvent($this, 'render: ' . $path, Logger::INFO));
             } else {
                 $values[$child->captureTo()] = $this->fallbackRenderer->render($child->getTemplate(), (array) $child->getVariables());
             }
             $child->setOption('has_parent', true);
         }
     }
     return $this->resolver->resolve($model->getTemplate(), $this)->render((array) $values);
 }
Ejemplo n.º 25
0
 /**
  * Generate paging html
  */
 private function generatePaging()
 {
     # Get total page count
     $pages = ceil($this->totalResults / $this->resultsPerPage);
     /* # Don't show pagination if there's only one page
             if($pages == 1)
             {
                 return;
             }
     
             # Show back to first page if not first page
             if($this->page != 1)
             {
             	$this->paging .= "<a href='".$this->baseUrl . '?page=1'."' /> << </a>";
             }
     
             # Create a link for each page
             $pageCount = 1;
             while($pageCount <= $pages)
             {
                 $this->paging .= "<a href='".$this->baseUrl . '?page='. $pageCount . "' /> ". $pageCount ." </a>";
                 $pageCount++;
             }
     
             # Show go to last page option if not the last page
             if($this->page != $pages)
             {
                 $this->paging .= "<a href='".$this->baseUrl . '?page='. $pages . "' /> >> </a>";
             }*/
     //return $this->paging;
     $renderer = new PhpRenderer();
     $resolver = new TemplateMapResolver();
     $resolver->setMap(array('pager' => __DIR__ . '/../../../../../GDI/view/gdi/index2/_pager.phtml'));
     $renderer->setResolver($resolver);
     $view = new ViewModel(array('pages' => $pages, 'current_page' => $this->page, 'baseUrl' => $this->baseUrl, 'pageCount' => 1));
     $view->setTemplate('pager');
     $content = $renderer->render($view);
     return $content;
 }
Ejemplo n.º 26
0
 public function testFromRenderWithEnctype()
 {
     $this->formConfig['variables']['inputFileExists'] = true;
     $factory = new Factory();
     $form = $factory->create($this->formConfig);
     $form->setData(['name' => 'Sample name', 'link' => '/bar/baz']);
     $rawHtml = $this->renderer->render($form);
     $this->assertEquals(preg_replace('/\\s+/', ' ', '<form method="post" action="/admin/news/create" enctype="multipart/form-data">
                 <div class="box-body">
                     <div class="form-group">
                         <label class="control-label">Name</label>
                         <input type="text" name="name" placeholder="Enter name" class="form-control" value="Sample name">
                     </div>
                     <div class="form-group">
                         <label class="control-label">Link</label>
                         <input type="text" name="link" placeholder="Enter link" class="form-control" value="/bar/baz">
                     </div>
                 </div>
                 <div class="box-footer">
                     <button type="submit" class="btn btn-success" id="submit-btn">Submit</button>
                     <a class="btn btn-default" href="/admin/list">Cancel</a>
                 </div>
             </form>'), preg_replace('/\\s+/', ' ', $rawHtml));
 }
 public function testAttemptingToRenderWithNoCurrentModelRaisesException()
 {
     $renderer = new PhpRenderer();
     $renderer->setResolver($this->resolver);
     $this->setExpectedException('Zend\View\Exception\RuntimeException', 'no view model');
     $renderer->render('layout');
 }
Ejemplo n.º 28
0
 /**
  * Function for getting the forgot password template
  *
  * @author Kaushal Kishore <*****@*****.**>
  * @package Users
  * @access Public
  * @return Ambigous <string, \Zend\Filter\mixed, mixed>
  */
 public function getForgotPasswordTemplate($variables = array())
 {
     $view = new PhpRenderer();
     $resolver = new TemplateMapResolver();
     $resolver->setMap(array('mailTemplate' => __DIR__ . '/../../../view/users/user/forgot-mail-template.phtml'));
     $view->setResolver($resolver);
     $viewModel = new \Zend\View\Model\ViewModel();
     $viewModel->setTemplate('mailTemplate');
     $viewModel->setVariables($variables);
     $content = $view->render($viewModel);
     return $content;
 }
Ejemplo n.º 29
0
 public function testAttemptingToRenderWithNoCurrentModelRaisesException()
 {
     $renderer = new PhpRenderer();
     $renderer->setResolver($this->resolver);
     $this->setExpectedException('Zend\\View\\Exception\\RuntimeException', 'no view model');
     $this->expectOutputString("Layout start" . PHP_EOL . PHP_EOL);
     $renderer->render('layout');
 }
Ejemplo n.º 30
0
 public function editAction()
 {
     $viewModel = new ViewModel();
     $viewModel->setTemplate("edit");
     $renderer = new PhpRenderer();
     $resolver = new Resolver\AggregateResolver();
     $renderer->setResolver($resolver);
     $map = new Resolver\TemplateMapResolver(array('edit' => __DIR__ . '/../../../view/application/wordage/edit.phtml'));
     $stack = new Resolver\TemplatePathStack(array('script_paths' => array(__DIR__ . '/view')));
     $resolver->attach($map);
     $resolver->attach($stack);
     $wordageid = $this->params()->fromQuery('id');
     // Looking for: wordage- or 8 chars
     $theId = substr($wordageid, strpos('-', $wordageid) + 8, strlen($wordageid));
     $viewModel->setVariable('theid', $theId);
     $theArray = array('id' => $theId);
     $em = $this->getEntityManager();
     $wordage = $em->getRepository('Application\\Entity\\Wordage')->findOneBy($theArray);
     $actualWords = $wordage->getWordage();
     $viewModel->setVariable('actualWords', $actualWords);
     $viewModel->setVariable('id', $theId);
     $variables = array("id" => $wordageid, "view" => $renderer->render($viewModel), "thewordage" => print_r($wordage, true));
     $jsonModel = new JsonModel($variables);
     $response = $this->getResponse();
     $response->setStatusCode(200);
     $response->setContent(json_encode($variables));
     return $response;
 }