예제 #1
0
파일: View.php 프로젝트: joycekenya/gliver
 /**
  *This method parses the input variables and loads the specified views
  *
  *@param string $filePath the string that specifies the view file to load
  *@param array $data an array with variables to be passed to the view file
  *@return void This method does not return anything, it directly loads the view file
  *@throws 
  */
 public static function render($filePath, array $data = null)
 {
     //this try block is excecuted to enable throwing and catching of errors as appropriate
     try {
         //get the variables passed and make them available to the view
         if ($data != null) {
             //loop through the array setting the respective variables
             foreach ($data as $key => $value) {
                 ${$key} = $value;
             }
         }
         //compose the file full path
         $path = Path::view($filePath);
         //get an instance of the view template class
         $template = Registry::get('template');
         //get the compiled file contents
         $contents = $template->compiled($path);
         //start the output buffer
         ob_start();
         //evaluate the contents of this view file
         eval("?>" . $contents . "<?");
         //get the evaluated contents
         $contents = ob_get_contents();
         //clean the output buffer
         ob_end_clean();
         //return the evaluated contents
         echo $contents;
         //stop further script execution
         exit;
     } catch (BaseException $e) {
         //echo $e->getMessage();
         $e->show();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #2
0
 /**
  *This method returns a query instance
  *
  *@param null
  *@return object Query instance
  */
 public static function Query()
 {
     static::$connection = Registry::get('database');
     static::$queryObject = static::$connection->query();
     return static::$queryObject;
 }
 /**
  *This model updates a table structure in the database.
  *@param null
  *@return bool true if update structure success
  */
 public static final function updateTable()
 {
     //call the method to update table structure in the database
     return (new MySQLTable(static::$table, get_called_class(), Registry::get('database')))->updateTable();
 }