diff --git a/trax/vendor/trax/action_view/handlers/haml.php b/trax/vendor/trax/action_view/handlers/haml.php index 863dc2c..43c1b71 100644 --- a/trax/vendor/trax/action_view/handlers/haml.php +++ b/trax/vendor/trax/action_view/handlers/haml.php @@ -3,9 +3,9 @@ class Haml { private $parser = null; - private $context = null; function __construct($context) { + parent::__construct($context); if(file_exists(Trax::$vendor_path."/phphaml/includes/haml/HamlParser.class.php")) { $haml_compile_path = Trax::$tmp_path."/haml"; if(!is_dir($haml_compile_path)) { @@ -20,24 +20,6 @@ function __construct($context) { } } - function __call($method_name, $parameters) { - if(method_exists($this, $method_name)) { - # If the method exists, just call it - $result = call_user_func_array(array($this, $method_name), $parameters); - } elseif(method_exists(Trax::$current_controller_object, $method_name)) { - $result = call_user_func_array(array(Trax::$current_controller_object, $method_name), $parameters); - } - return $result; - } - - function __get($key) { - if(property_exists($this, $key)) { - return $this->$key; - } elseif(property_exists(Trax::$current_controller_object, $key)) { - return Trax::$current_controller_object->{$key}; - } - } - function render($path, $locals = array()) { if(count($locals)) { foreach($locals as $key => $value) { diff --git a/trax/vendor/trax/action_view/handlers/handler_base.php b/trax/vendor/trax/action_view/handlers/handler_base.php new file mode 100644 index 0000000..a2ec8af --- /dev/null +++ b/trax/vendor/trax/action_view/handlers/handler_base.php @@ -0,0 +1,40 @@ +context = $context; + } + + function __call($method_name, $parameters) { + if(method_exists($this, $method_name)) { + # If the method exists, just call it + $result = call_user_func_array(array($this, $method_name), $parameters); + } elseif(method_exists(Trax::$current_controller_object, $method_name)) { + $result = call_user_func_array(array(Trax::$current_controller_object, $method_name), $parameters); + } + return $result; + } + + function __get($key) { + if(in_array($key, self::$vars)) { + return self::$vars[$key]; + } elseif(property_exists($this, $key)) { + return $this->$key; + } elseif(property_exists(Trax::$current_controller_object, $key)) { + return Trax::$current_controller_object->{$key}; + } + } + + function __set($key, $value) { + self::$vars[$key] = $value; + $this->{$key} = $value; + } + + function render($path, $locals = array()) { + echo "Please implement me in child class!"; + } +} +?> \ No newline at end of file diff --git a/trax/vendor/trax/action_view/handlers/html.php b/trax/vendor/trax/action_view/handlers/html.php index c7028b2..9f511d4 100644 --- a/trax/vendor/trax/action_view/handlers/html.php +++ b/trax/vendor/trax/action_view/handlers/html.php @@ -1,30 +1,6 @@ context = $context; - } - - function __call($method_name, $parameters) { - if(method_exists($this, $method_name)) { - # If the method exists, just call it - $result = call_user_func_array(array($this, $method_name), $parameters); - } elseif(method_exists(Trax::$current_controller_object, $method_name)) { - $result = call_user_func_array(array(Trax::$current_controller_object, $method_name), $parameters); - } - return $result; - } - - function __get($key) { - if(property_exists($this, $key)) { - return $this->$key; - } elseif(property_exists(Trax::$current_controller_object, $key)) { - return Trax::$current_controller_object->{$key}; - } - } +class Html extends HandlerBase { function render($path, $locals = array()) { if(count($locals)) { diff --git a/trax/vendor/trax/action_view/view_handlers.php b/trax/vendor/trax/action_view/view_handlers.php index 6ae89c2..cc063ca 100644 --- a/trax/vendor/trax/action_view/view_handlers.php +++ b/trax/vendor/trax/action_view/view_handlers.php @@ -1,5 +1,7 @@