Last active
February 11, 2019 11:41
-
-
Save joaohcrangel/a5b9aba529303c829367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Page { | |
public $options = array( | |
"data"=>array( | |
"js"=>array(), | |
"title"=>"", | |
"meta_description"=>"", | |
"meta_author"=>"João Rangel" | |
) | |
); | |
public function __construct($options = array()){ | |
$options = array_merge($this->options, $options); | |
$tpl = $this->getTpl(); | |
$this->options = $options; | |
if(gettype($this->options['data'])=='array'){ | |
foreach($this->options['data'] as $key=>$val){ | |
$tpl->assign($key, $val); | |
} | |
} | |
$tpl->draw("header", false); | |
} | |
public function __destruct(){ | |
$tpl = $this->getTpl(); | |
if(gettype($this->options['data'])=='array'){ | |
foreach($this->options['data'] as $key=>$val){ | |
$tpl->assign($key, $val); | |
} | |
} | |
$tpl->draw("footer", false); | |
} | |
public function setTpl($tplname, $data = array(), $returnHTML = false){ | |
$tpl = $this->getTpl(); | |
if(gettype($data)=='array'){ | |
foreach($data as $key=>$val){ | |
$tpl->assign($key, $val); | |
} | |
} | |
return $tpl->draw($tplname, $returnHTML); | |
} | |
public function getTpl(){ | |
return ($this->Tpl)?$this->Tpl:$this->Tpl = new RainTPL; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment