当前位置: 首页>>代码示例>>PHP>>正文


PHP Renderer\PhpRenderer类代码示例

本文整理汇总了PHP中Zend\View\Renderer\PhpRenderer的典型用法代码示例。如果您正苦于以下问题:PHP PhpRenderer类的具体用法?PHP PhpRenderer怎么用?PHP PhpRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PhpRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PdfAction

 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');
 }
开发者ID:vikas1monu,项目名称:ProductionWsr,代码行数:35,代码来源:IndexController.php

示例2: onRoute

 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;
 }
开发者ID:zend-modules,项目名称:maintenance,代码行数:58,代码来源:MaintenanceListener.php

示例3: form

 /**
  * {@inheritDoc}
  */
 public function form(PhpRenderer $view, array $options = [])
 {
     $urlInput = new UrlElement('o:media[__index__][o:source]');
     $urlInput->setOptions(['label' => $view->translate('oEmbed URL'), 'info' => $view->translate('URL for the media to embed.')]);
     $urlInput->setAttributes(['id' => 'media-oembed-source-__index__', 'required' => true]);
     return $view->formRow($urlInput);
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:10,代码来源:OEmbed.php

示例4: setUp

 protected function setUp()
 {
     $this->view = new PhpRenderer();
     $this->view->getHelperPluginManager()->get('basePath')->setBasePath('/');
     $this->helper = new Resize();
     $this->helper->setView($this->view);
 }
开发者ID:tck,项目名称:zf2-imageresizer,代码行数:7,代码来源:ResizeTest.php

示例5: __invoke

 /**
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($container->get('ViewHelperManager'));
     $renderer->setResolver($container->get('ViewResolver'));
     return $renderer;
 }
开发者ID:kuisatz,项目名称:ustalarMerkezi,代码行数:13,代码来源:ViewPhpRendererFactory.php

示例6: __invoke

 /**
  * @param ContainerInterface $container
  *
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $helper = $container->get(HelperPluginManager::class);
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helper);
     return $renderer;
 }
开发者ID:oqq,项目名称:ci-zend-form-twig-extension,代码行数:12,代码来源:ZendFormPhpRendererFactory.php

示例7: testApplyViewHelpers

 public function testApplyViewHelpers()
 {
     $config = Bootstrap::getServiceManager()->get('Config');
     $helperPluginManager = new HelperPluginManager();
     $listener = new ViewHelperListener($this->layoutUpdater, $helperPluginManager, $config['con-layout']['view_helpers']);
     $mvcEvent = new \Zend\Mvc\MvcEvent();
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helperPluginManager);
     $basePath = $helperPluginManager->get('basePath');
     $basePath->setBasePath('/assets');
     $basePathAssetPreparer = new BasePath($basePath);
     $listener->addAssetPreparer('headLink', $basePathAssetPreparer);
     /* @var $headLink HeadLink */
     $headLink = $helperPluginManager->get('headLink');
     /* @var $headScript HeadScript */
     $headScript = $helperPluginManager->get('headScript');
     /* @var $doctype \Zend\View\Helper\Doctype */
     $doctype = $helperPluginManager->get('doctype');
     /* @var $headTitle HeadTitle */
     $headTitle = $helperPluginManager->get('headTitle');
     /* @var $headMeta HeadMeta */
     $headMeta = $helperPluginManager->get('headMeta');
     $headMeta->setView($renderer);
     $listener->applyViewHelpers($mvcEvent);
     $expected = '<link href="/assets/css/test.css" media="screen" rel="stylesheet" type="text/css">' . PHP_EOL . '<link href="/assets/css/main.css" media="screen" rel="stylesheet" type="text/css">';
     $this->assertEquals($expected, $headLink->toString());
     $expected = '<script type="text/javascript" src="/js/jquery.min.js"></script>' . PHP_EOL . '<script type="text/javascript" src="/js/jquery-ui.min.js"></script>' . PHP_EOL . '<!--[if lt IE 9]><script type="text/javascript" src="/js/modernizr.js"></script><![endif]-->' . PHP_EOL . '<script type="text/javascript" src="/js/functions.js"></script>';
     $this->assertEquals($expected, $headScript->toString());
     $this->assertEquals('<!DOCTYPE html>', (string) $doctype);
     $headTitle->setSeparator(' | ');
     $expected = '<title>First | My Title | Another Title</title>';
     $this->assertEquals($expected, $headTitle->toString());
     $expected = '<meta charset="utf8">' . PHP_EOL . '<meta name="description" content="My description">' . PHP_EOL . '<meta name="keywords" content="keyword1, keyword2, keyword3">';
     $this->assertEquals($expected, $headMeta->toString());
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:35,代码来源:ViewHelperListenerTest.php

示例8: renderSpellingSuggestions

 /**
  * Support function to display spelling suggestions.
  *
  * @param string                          $msg     HTML to display at the top of
  * the spelling section.
  * @param \VuFind\Search\Base\Results     $results Results object
  * @param \Zend\View\Renderer\PhpRenderer $view    View renderer object
  *
  * @return string
  */
 public function renderSpellingSuggestions($msg, $results, $view)
 {
     $spellingSuggestions = $results->getSpellingSuggestions();
     if (empty($spellingSuggestions)) {
         return '';
     }
     $html = '<div class="' . $this->getContainerClass() . '">';
     $html .= $msg;
     foreach ($spellingSuggestions as $term => $details) {
         $html .= '<br/>' . $view->escapeHtml($term) . ' &raquo; ';
         $i = 0;
         foreach ($details['suggestions'] as $word => $data) {
             if ($i++ > 0) {
                 $html .= ', ';
             }
             $html .= '<a href="' . $results->getUrlQuery()->replaceTerm($term, $data['new_term']) . '">' . $view->escapeHtml($word) . '</a>';
             if (isset($data['expand_term']) && !empty($data['expand_term'])) {
                 $url = $results->getUrlQuery()->replaceTerm($term, $data['expand_term']);
                 $html .= $this->renderExpandLink($url, $view);
             }
         }
     }
     $html .= '</div>';
     return $html;
 }
开发者ID:tillk,项目名称:vufind,代码行数:35,代码来源:AbstractSearch.php

示例9: setUp

 /**
  * Prepares the environment before running a test
  *
  */
 protected function setUp()
 {
     $cwd = __DIR__;
     // read navigation config
     $this->_files = $cwd . '/_files';
     $config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
     // setup containers from config
     $this->_nav1 = new Navigation($config->get('nav_test1'));
     $this->_nav2 = new Navigation($config->get('nav_test2'));
     // setup view
     $view = new PhpRenderer();
     $view->resolver()->addPath($cwd . '/_files/mvc/views');
     // create helper
     $this->_helper = new $this->_helperName();
     $this->_helper->setView($view);
     // set nav1 in helper as default
     $this->_helper->setContainer($this->_nav1);
     // setup service manager
     $smConfig = array('modules' => array(), 'module_listener_options' => array('config_cache_enabled' => false, 'cache_dir' => 'data/cache', 'module_paths' => array(), 'extra_config' => array('service_manager' => array('factories' => array('Config' => function () use($config) {
         return array('navigation' => array('default' => $config->get('nav_test1')));
     })))));
     $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig());
     $sm->setService('ApplicationConfig', $smConfig);
     $sm->get('ModuleManager')->loadModules();
     $sm->get('Application')->bootstrap();
     $sm->setFactory('Navigation', 'Zend\\Navigation\\Service\\DefaultNavigationFactory');
     $sm->setService('nav1', $this->_nav1);
     $sm->setService('nav2', $this->_nav2);
     $app = $this->serviceManager->get('Application');
     $app->getMvcEvent()->setRouteMatch(new RouteMatch(array('controller' => 'post', 'action' => 'view', 'id' => '1337')));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:35,代码来源:AbstractTest.php

示例10: testCanRenderFieldsets

 /**
  * @outputBuffering disabled
  */
 public function testCanRenderFieldsets()
 {
     $this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/');
     $form = new NetsensiaForm();
     $form->addHidden('test1', 'testvalue');
     $hidden = new Element\Hidden('asdasd');
     $hidden->setValue('123');
     $form->add($hidden);
     $element1 = new Text('testelement1');
     $element1->setLabel('Test Element');
     $element1->setAttribute('icon', 'pencil');
     $element2 = new Text('testelement2');
     $element2->setLabel('Test Element 2');
     $element2->setAttribute('icon', 'pencil');
     $fieldset1 = new Fieldset('testfieldset1');
     $fieldset1->add($element1);
     $fieldset2 = new Fieldset('testfieldset2');
     $fieldset2->add($element2);
     $form->add($fieldset1);
     $form->add($fieldset2);
     $helpers = new HelperPluginManager();
     $helpers->setService('formElement', new FormElement());
     $view = new PhpRenderer();
     $view->setHelperPluginManager($helpers);
     $viewHelper = new BootstrapForm();
     $viewHelper->setView($view);
     $viewHelper($form, 'testform', '/');
 }
开发者ID:netsensia,项目名称:zf2-foundation,代码行数:31,代码来源:BootstrapFormTest.php

示例11: setUp

 public function setUp()
 {
     $this->wrapperHelper = new Wrapper();
     $view = new PhpRenderer();
     $view->setHelperPluginManager(new HelperPluginManager());
     $this->wrapperHelper->setView($view);
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:7,代码来源:WrapperTest.php

示例12: render

 public function render(PhpRenderer $view, SitePageBlockRepresentation $block)
 {
     $attachments = $block->attachments();
     if (!$attachments) {
         return '';
     }
     $html = '';
     foreach ($attachments as $attachment) {
         $html .= '<div>';
         $item = $attachment->item();
         if ($item) {
             $html .= '<h2>' . $item->link($item->displayTitle()) . '</h2>';
             $media = $attachment->media();
             if (!$media) {
                 $media = $item->primaryMedia();
             }
             if ($media) {
                 $thumbnailType = $this->getData($block->data(), 'thumbnail_type', 'square');
                 $html .= '<h3>' . $media->link($media->displayTitle()) . '</h3>';
                 $html .= '<img src="' . $view->escapeHtml($media->thumbnailUrl($thumbnailType)) . '">';
             }
         }
         $caption = $attachment->caption();
         if ($caption) {
             $html .= '<p>' . $caption . '</p>';
         }
         $html .= '</div>';
     }
     return $html;
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:30,代码来源:ItemList.php

示例13: setUp

 public function setUp()
 {
     $this->transport = new MockTransport();
     $config = (include __DIR__ . '/../../config/module.config.php');
     $renderer = new PhpRenderer();
     $renderer->setResolver(new TemplatePathStack($config['view_manager']['template_path_stack']));
     $this->mailService = new MailService(new Message(), $this->transport, $renderer);
 }
开发者ID:quangdungninh,项目名称:zendvnteam,代码行数:8,代码来源:MailServiceTest.php

示例14: render

 /**
  * @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;
 }
开发者ID:enlitepro,项目名称:enlite-mail,代码行数:32,代码来源:Template.php

示例15: render

 public function render($variables, $template)
 {
     $this->phpRenderer->setVars($variables);
     $result = $this->phpRenderer->render($template);
     $this->phpRenderer->setVars(array());
     return $result;
 }
开发者ID:kidaa,项目名称:evedata,代码行数:7,代码来源:Renderer.php


注:本文中的Zend\View\Renderer\PhpRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。