registry = $registry; // set registry object } public function __set($index, $value) // magic method yang berfungsi untuk set variable untuk template saja { $this->vars[$index] = $value; } // ini method yang berfungsi untuk menampilkan view function show($name,$listJS= array(),$listCSS= array()) { // variable path berfungsi menyimpan path file view $path = __SITE_PATH .'/src/modules/'.$this->registry->ContPath. '/views' . '/' . $name . '.php'; $pathJS= __SITE_PATH .'/src/modules/'.$this->registry->ContPath. '/js' . '/' . $name . '.js'; $srcjs= __SERVERADDR.'/src/modules'.$this->registry->ContPath. '/js' . '/' . $name . '.js'; $pathCSS= __SITE_PATH .'/src/modules/'.$this->registry->ContPath. '/css' . '/' . $name . '.css'; $srccss= __SERVERADDR.'/src/modules'.$this->registry->ContPath. '/css' . '/' . $name . '.css'; if (file_exists($path) == false) { throw new \Exception('Template not found in '. $path); return false; } // Load variables, jadikan index array sebagai variable pada php foreach ($this->vars as $key => $value) { //set variable php $$key = $value; } if(sizeof($listCSS)>0) { foreach ($listCSS as $val) { echo ""; } } // include file if (file_exists($pathCSS) == true) { echo ""; } include ($path); // load view if (file_exists($pathJS) == true) { echo ""; } if(sizeof($listJS)>0) { foreach ($listJS as $val) { echo ""; } } } /** * method ini digunakan untuk menampilkan data dalam PDF * require dompdf */ public function getContentFile($name) { $path = __SITE_PATH .'/src/modules/'.$this->registry->ContPath. '/pdf' . '/' . $name . '.php'; if (file_exists($path) == false) { throw new \Exception('Template not found in '. $path); return false; } // Load variables, jadikan index array sebagai variable pada php foreach ($this->vars as $key => $value) { //set variable php $$key = $value; } $obstart=ob_start(); if ($obstart == false) { throw new \Exception('output bueffering not start '); return false; } include ($path); // load view $out = ob_get_clean(); return $out; } } ?>