コード例 #1
0
 /**
  * Erzeugt ein PDF auf Basis der übergebenen Funktion.
  * @param $module
  * @param $action
  * @param $param
  * @param null $filename falls kein Dateiname angegeben wird, wird das PDF direkt im Browser ausgegeben
  * @throws \Exception
  */
 public static function generate($module, $action, $param, $filename = null, $template = true, $margin = 0)
 {
     $druckinhalt = new WrapperControl(null, 'druck');
     $druckinhalt->setModule($module)->setAction($action)->addParams($param);
     $pdf = new \mPDF('de-DE', 'A4');
     $pdf->SetDisplayMode('fullpage');
     // Zeigt eine ganze Seite an, wenn das PDF in Acrobat geöffnet wird
     if ($margin > 0) {
         $pdf->SetTopMargin($margin);
     }
     $pdf->SetFooter('Seite {PAGENO} / {nb}');
     //file_get_contents('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css') .
     $stylesheet = file_get_contents('templates/print/css/default.css');
     $pdf->WriteHTML($stylesheet, 1);
     if ($template && file_exists('site/Print.template.html')) {
         $vars = ['heading' => Application::getCurrentResponse()->getMetadata()->getHeading()];
         $header = Parser::parse(null, null, $vars, file_get_contents('site/Print.template.html'));
         $pdf->WriteHTML($header, 2);
     }
     $pdf->WriteHTML($druckinhalt->toHtml(), 2);
     if ($filename === null) {
         $pdf->Output($module . $action . '.pdf', 'I');
     } else {
         //$filename = Files::validateFilename($filename);
         $pdf->Output($filename, 'F');
     }
     unset($pdf);
 }
コード例 #2
0
 /**
  * @covers \NewFrontiers\Framework\Output\Parser::parse
  * @covers \NewFrontiers\Framework\Output\Parser::getReplacement
  * @covers \NewFrontiers\Framework\Output\Parser::getWertFromEntity
  * @covers \NewFrontiers\Framework\Output\Parser::getWertFromVars
  */
 public function testParse()
 {
     $instance = Parser::getInstance();
     $instance->editMode = true;
     $entity = $this->createMock(BaseEntity::class);
     $control = new PanelControl(null, "ungewöhnliche ID");
     $template = "This is {my} {thisControl.id} on {site.url}. " . "This is a {control_var} {controls}" . "<?php echo 'Merged'; echo 'string'; ?>";
     //$ts = "{hallo}";
     $result = Parser::parse($entity, $control, ["thisControl" => $entity], $template);
     //var_dump($result);
     $this->assertContains("This is", $result);
     $this->assertContains("This", $result);
     $this->assertContains("Mergedstring", $result);
     $result = Parser::parse($entity, $control, [], $template);
     //var_dump($result);
     /*$this->assertContains("Und", end($items)["msg"]);
       print_r(end($items)["msg"]);*/
 }
コード例 #3
0
 /**
  * Generiert den HTML-Code des Controls auf Basis der aktuellen Skin
  * @return string
  */
 public function renderBySkin()
 {
     $this->loadSkin();
     $this->setVar('css', $this->getCssString());
     $this->setVar('id', $this->getId());
     $result = Parser::parse($this->entity, $this, $this->vars, $this->skin);
     return $result;
 }
コード例 #4
0
 /**
  * Gibt den Text einer Spalte aus. Ist ein Template vorhanden, so wird
  * dieses ggf. geparst und dann die Daten ausgegeben. Ohne Template
  * wird das entsprchende Feld zurückgegeben
  *
  * @param array $row
  * @return string
  */
 public function getData($row)
 {
     if (isset($this->template)) {
         $variables = array($this->data);
         // array_merge($row, $this->data);
         return Parser::parse($this->entity, null, $variables, $this->template, $this->matches);
     } elseif (isset($this->text)) {
         return $this->text;
     } elseif (isset($this->entity) && (isset($this->field) && $this->entity->hasField($this->field))) {
         return $this->entity->felder[$this->field]->toString();
     } else {
         return "";
     }
 }