Skip to content

Instantly share code, notes, and snippets.

@joaohcrangel
Last active February 11, 2019 11:41
Show Gist options
  • Save joaohcrangel/a5b9aba529303c829367 to your computer and use it in GitHub Desktop.
Save joaohcrangel/a5b9aba529303c829367 to your computer and use it in GitHub Desktop.
<?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