View Source
/hsphere/local/home/c251266/sunsetvines.com/www.sunsetvines.com/sunsetvines/current/vendor/creovel/classes/view.php (2.245 KB)
#0001
#0002
#0003
#0004
#0005
#0006
#0007
#0008
#0009
#0010
#0011
#0012
#0013
#0014
#0015
#0016
#0017
#0018
#0019
#0020
#0021
#0022
#0023
#0024
#0025
#0026
#0027
#0028
#0029
#0030
#0031
#0032
#0033
#0034
#0035
#0036
#0037
#0038
#0039
#0040
#0041
#0042
#0043
#0044
#0045
#0046
#0047
#0048
#0049
#0050
#0051
#0052
#0053
#0054
#0055
#0056
#0057
#0058
#0059
#0060
#0061
#0062
#0063
#0064
#0065
#0066
#0067
#0068
#0069
#0070
#0071
#0072
#0073
#0074
#0075
#0076
#0077
#0078
#0079
#0080
#0081
#0082
#0083
#0084
#0085
#0086
#0087
#0088
#0089
#0090
#0091
#0092
#0093
#0094
#0095
#0096
#0097
#0098
#0099
#0100
#0101
#0102
#0103
|
<?php /** * View class * */ class view { /** * Creates the page to be displayed and sets it to the page property * * @author Nesbert Hidalgo * @access public * @param string $view_path * @param string $layout_path */ public function _create_view($view_path, $layout_path, $options = null) { try { // set content data $content = $options['text']; if ( $options['render'] !== false ) { $content .= self::_get_include_contents($view_path, $options); } // combine content and template. else use content only switch ( true ) { case ( $options['layout'] !== false ): if ( file_exists($layout_path) ) { $page = str_replace('@@page_contents@@', $content, self::_get_include_contents($layout_path, $options)); } else { throw new Exception("Unable to render 'layout'. File not found <strong>{$layout_path}</strong>."); } break; default: $page = $content; break; } return $page; } catch ( Exception $e ) { // add to errors $_ENV['error']->add($e->getMessage()); } } /** * Return the page to be displayed as string * * @author Nesbert Hidalgo * @access public * @return string */ public function _get_view($view_path = null, $layout_path = null, $options = null) { return self::_create_view($view_path, $layout_path, $options); }
/** * Print page to screen * * @author Nesbert Hidalgo * @access public */ public function _show_view($view_path = null, $layout_path = null, $options = null) { print self::_create_view($view_path, $layout_path, $options); }
/* * http://us3.php.net/manual/en/function.include.php * Example 16-11. Using output buffering to include a PHP file into a string * * @author Nesbert Hidalgo * @access public * @param string $filename * @return string */ public function _get_include_contents($filename, $options = null) { if ( is_file($filename) ) { ob_start(); // create a variable foreach option, using its key as the vairable name if ( count($options) ) foreach ( $options as $key => $values ) $$key = $values;
include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false; } } ?>
|