Navigation Menu

Skip to content

Commit

Permalink
fixed views setting and getting this->
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpipi committed Nov 20, 2013
1 parent ea5bb85 commit 3def8f9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
20 changes: 1 addition & 19 deletions trax/vendor/trax/action_view/handlers/haml.php
Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down
40 changes: 40 additions & 0 deletions trax/vendor/trax/action_view/handlers/handler_base.php
@@ -0,0 +1,40 @@
<?
class HandlerBase {

protected $context = null;
protected static $vars = array();

function __construct($context) {
$this->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!";
}
}
?>
26 changes: 1 addition & 25 deletions trax/vendor/trax/action_view/handlers/html.php
@@ -1,30 +1,6 @@
<?

class Html {

private $context = null;

function __construct($context) {
$this->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)) {
Expand Down
2 changes: 2 additions & 0 deletions trax/vendor/trax/action_view/view_handlers.php
@@ -1,5 +1,7 @@
<?

include_once(TRAX_LIB_ROOT."/action_view/handlers/handler_base.php");

class ViewHandlers {

private static $extensions = array();
Expand Down

0 comments on commit 3def8f9

Please sign in to comment.