Skip to content

Commit 9a687f3

Browse files
committed
dev
1 parent 65bacda commit 9a687f3

File tree

2 files changed

+47
-48
lines changed

2 files changed

+47
-48
lines changed

MVC.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
define('MVC_VERSION', '0.0.4');
1111

1212
//carrega classes do core
13-
require __DIR__.'/Session.php';
14-
require __DIR__.'/View.php';
15-
require __DIR__.'/Controller.php';
13+
require __DIR__.'/Session.php'; //{{Session.php}}
14+
require __DIR__.'/View.php'; //{{View.php}}
15+
require __DIR__.'/Controller.php'; //{{Controller.php}}
1616

1717
class MVC{
1818
private static $_config = array();

View.php

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
1-
<?php
2-
3-
class View {
4-
protected $_file;
5-
protected $_data = array();
6-
protected $_withTemplate = true;
7-
8-
9-
public $content = "";
10-
11-
public function __construct($file) {
12-
$this->_file = $file;
13-
}
14-
15-
public function set($key, $value) {
16-
$this->_data[$key] = $value;
17-
}
18-
19-
public function get($key) {
20-
return isset($this->_data[$key]) ? $this->_data[$key] : '';
21-
}
22-
23-
public function withTemplate($value){
24-
$this->_withTemplate = $value;
25-
}
26-
27-
public function output(){
28-
if ($this->_withTemplate){
29-
if (!file_exists($this->_file)){
30-
throw new Exception("Template " . $this->_file . " doesn't exist.");
31-
}
32-
}
33-
34-
extract($this->_data);
35-
36-
ob_start();
37-
if ($this->_withTemplate){
38-
include($this->_file);
39-
}
40-
$this->content = ob_get_contents();
41-
ob_end_clean();
42-
43-
return $this->content;
44-
}
45-
}
1+
<?php
2+
3+
class View {
4+
protected $_file;
5+
protected $_data = array();
6+
protected $_withTemplate = true;
7+
8+
public $content = "";
9+
10+
public function __construct($file) {
11+
$this->_file = $file;
12+
}
13+
14+
public function set($key, $value) {
15+
$this->_data[$key] = $value;
16+
}
17+
18+
public function get($key) {
19+
return isset($this->_data[$key]) ? $this->_data[$key] : '';
20+
}
21+
22+
public function withTemplate($value){
23+
$this->_withTemplate = $value;
24+
}
25+
26+
public function output(){
27+
if ($this->_withTemplate){
28+
if (!file_exists($this->_file)){
29+
throw new Exception("Template " . $this->_file . " doesn't exist.");
30+
}
31+
}
32+
33+
extract($this->_data);
34+
35+
ob_start();
36+
if ($this->_withTemplate){
37+
include($this->_file);
38+
}
39+
$this->content = ob_get_contents();
40+
ob_end_clean();
41+
42+
return $this->content;
43+
}
44+
}

0 commit comments

Comments
 (0)