31. View
<?php
class View {
private $_vars = array();
public function __set($name, $val) {
$this->_vars[$name] = $val;
}
public function __get($name) {
return isset($this->_vars[$name])
? $this->_vars[$name]
: null;
}
public function display($tpl) {
include $tpl;
}
}
53. mvc.js (Model)
myapp.Model = function () {
var val = 0;
this.add = function (v) {
val += v;
};
this.sub = function (v) {
val -= v;
};
this.getVal = function () {
return val;
};
};
54. mvc.js (Presenter)
myapp.Presenter = function () {
var model = null;
this.init = function () {
model = new myapp.Model();
};
this.increase = function () {
model.add(1);
};
this.decrease = function () {
model.sub(1);
};
this.getModel = function () {
return model;
}
};