Example #1
0
 /**
  * Process the template
  * @return boolean|string
  *
  * This function process the template. If $this->renderas is set, it
  * will produce a full page.
  */
 public function fetchPage()
 {
     $data = parent::fetchPage();
     if ($this->renderas) {
         $page = new OC_TemplateLayout($this->renderas, $this->app);
         // Add custom headers
         $page->assign('headers', $this->headers, false);
         foreach (OC_Util::$headers as $header) {
             $page->append('headers', $header);
         }
         $page->assign("content", $data, false);
         return $page->fetchPage();
     } else {
         return $data;
     }
 }
Example #2
0
 /**
  * Process the template
  * @return boolean|string
  *
  * This function process the template. If $this->renderAs is set, it
  * will produce a full page.
  */
 public function fetchPage()
 {
     $data = parent::fetchPage();
     if ($this->renderAs) {
         $page = new OC_TemplateLayout($this->renderAs, $this->app);
         // Add custom headers
         $headers = '';
         foreach (OC_Util::$headers as $header) {
             $headers .= '<' . \OCP\Util::sanitizeHTML($header['tag']);
             foreach ($header['attributes'] as $name => $value) {
                 $headers .= ' ' . \OCP\Util::sanitizeHTML($name) . '="' . \OCP\Util::sanitizeHTML($value) . '"';
             }
             if ($header['text'] !== null) {
                 $headers .= '>' . \OCP\Util::sanitizeHTML($header['text']) . '</' . \OCP\Util::sanitizeHTML($header['tag']) . '>';
             } else {
                 $headers .= '/>';
             }
         }
         $page->assign('headers', $headers);
         $page->assign('content', $data);
         return $page->fetchPage();
     }
     return $data;
 }
Example #3
0
 /**
  * @param string $expectedHtml
  * @param string $template
  * @param array $vars
  */
 protected function assertTemplate($expectedHtml, $template, $vars = [])
 {
     require_once __DIR__ . '/../../lib/private/legacy/template/functions.php';
     $requestToken = 12345;
     $theme = new OC_Defaults();
     /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject $l10n */
     $l10n = $this->getMockBuilder('\\OCP\\IL10N')->disableOriginalConstructor()->getMock();
     $l10n->expects($this->any())->method('t')->will($this->returnCallback(function ($text, $parameters = array()) {
         return vsprintf($text, $parameters);
     }));
     $t = new Base($template, $requestToken, $l10n, $theme);
     $buf = $t->fetchPage($vars);
     $this->assertHtmlStringEqualsHtmlString($expectedHtml, $buf);
 }