first commit
This commit is contained in:
37
libraries/grid/grid-view.php
Normal file
37
libraries/grid/grid-view.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
class gridView
|
||||
{
|
||||
protected $_dir = 'templates/';
|
||||
protected $_vars = array();
|
||||
|
||||
function __construct( $dir = null )
|
||||
{
|
||||
if ( $dir !== null )
|
||||
$this -> _dir = $dir;
|
||||
}
|
||||
|
||||
public function render( $file )
|
||||
{
|
||||
if ( file_exists( $this -> _dir . $file . '.php' ) )
|
||||
{
|
||||
ob_start();
|
||||
include $this -> _dir . $file . '.php';
|
||||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
throw new Exception( 'No template file ' . $file . ' present in directory ' . $this -> _dir );
|
||||
}
|
||||
|
||||
public function __set( $name, $value )
|
||||
{
|
||||
$this -> _vars[ $name ] = $value;
|
||||
}
|
||||
|
||||
public function __get( $name )
|
||||
{
|
||||
return $this -> _vars[ $name ];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user