录医案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

9 months ago
<?php
include_once SERVER_ROOT . '/library/viewtpl/extSmarty.php';
include_once SERVER_ROOT . '/library/viewtpl/iDisplay.php';
class DisplaySmarty implements iDisplay {
private $smarty;
private $template;
public function __construct($template, $tpl_dir='') {
// 私有路径传递
$this->smarty = new extSmarty($tpl_dir);
$this->template = $template;
}
public function setView($view) {
$this->view = $view;
}
public function execute() {
if(is_array($this->view)) {
foreach($this->view as $key => $value ) {
$this->smarty->assign($key, $value);
}
}
$this->smarty->display($this->template);
}
public function save($html_path){
if(is_array($this->view)) {
foreach($this->view as $key => $value ) {
$this->smarty->assign($key, $value);
}
}
if(!file_exists(dirname($html_path))) mkdir(dirname($html_path), 0755, true);
file_put_contents($html_path, $this->smarty->fetch($this->template));
}
}