Unnamed Fossil Project

Check-in [fc60da8312]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some minor changes. Added view.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fc60da831291c84d820fd330b8919f92852f6899
User & Date: Spravce 2012-11-17 12:44:06
Context
2012-11-17
14:17
Added logger. check-in: 6cf0061409 user: Spravce tags: trunk
12:44
Some minor changes. Added view. check-in: fc60da8312 user: Spravce tags: trunk
2012-10-07
18:23
Improved exception handling. Production mode now by default. check-in: bb6b91d687 user: Spravce tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to brickyard.html.

5
6
7
8
9
10
11
12
13
14


15
16
17
18
19
20
21
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
250
251
252
253
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301





















302
303
304
305
306
307
308
...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
...
462
463
464
465
466
467
468



















































469
470
471
472
473
474
475
...
513
514
515
516
517
518
519




520
521
522
523
524
525
526
527
528
529
530
	<title>Brickyard framework</title>
	<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>

<h1>Brickyard framework</h1>

<p>Yet another php framework.</p>

<p>It aims to be simpler and smaller than others. Not suitable for enterprise.</p>



<h2>Usage</h2>

<p>The usage is really simple. Minimal index.php file (an entry point and setup) look like this:</p>

<p>Firstly you need to include framework file and get one instance.</p>

................................................................................


<pre id="run" title="run">
ob_start();
</pre>


<p>Get from router current controller, method and it's arguments. Note that controller has _c prefix before it's class name.</p>


<pre id="run" title="run">
$controllerName = &quot;c_&quot; . $this-&gt;router-&gt;getController();
$methodName = $this-&gt;router-&gt;getMethod();
$args = $this-&gt;router-&gt;getArgs();
</pre>
................................................................................

<h3>Exception handling</h3>

<p>If framework is in develMode, we will show debug message.</p>


<pre id="exception handling" title="exception handling">
if ($this-&gt;develMode){
    $this-&gt;bluescreen($e);
} else {
    &lt;&lt;detect type of exception&gt;&gt;
    &lt;&lt;show error message&gt;&gt;
}
</pre>

................................................................................
<p>But also in this case we need to check if error page is present.</p>


<pre id="show error message" title="show error message">
if (file_exists($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html')){
    ob_clean();
    echo file_get_contents($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html');

}else{
    echo &quot;An error occured. Also error page is missing.&quot;;
}
</pre>


<h2>Bluescreen</h2>

<p>Before showing any debug message we will erase output.</p>


<pre id="bluescreen" title="bluescreen">
ob_clean();
</pre>
................................................................................


<pre id="init" title="init">
set_exception_handler(array($this,&quot;exception_handler&quot;));
</pre>



<h3>Default values</h3>

<p>For now we are in devel mode permanently.</p>



<pre id="defaults" title="defaults">
public $develMode = false;
public $router = null;
public $libPath = '.';
public $indexPath = '.';
</pre>


<p>Some default instances are created in constructor.</p>


<pre id="defaults" title="defaults">
public function __construct(){
    $this-&gt;router = new brickyard_router_default;
    $this-&gt;libPath = dirname(__FILE__);

}
</pre>


<h2>Setters and getters</h2>

<p>Today we have setter and getter or router.</p>


<pre id="getters" title="getters">
public function getRouter()
{
    return $this-&gt;router;
}
</pre>



<pre id="setters" title="setters">
public function setRouter($router)
{
    $this-&gt;router = $router;
}
</pre>























<p>And for indexPath.</p>


<pre id="getters" title="getters">
public function getIndexPath()
................................................................................

<pre id="setters" title="setters">
public function setIndexPath($indexFilePath)
{
    $this-&gt;indexPath = dirname($indexFilePath);
}
</pre>



<h3>Brickyard class definition</h3>


<pre id="class brickyard" title="class brickyard">
class brickyard
................................................................................
interface brickyard_router_interface
{
    &lt;&lt;router interface code&gt;&gt;
}
</pre>


<p>We have an interface for router. Later there will be setRouter function which will enable using of more complicated routers than default one.</p>


<pre id="router interface code" title="router interface code">
public function getController();
</pre>


................................................................................
            }
        }
        return $url;
    }
}
</pre>





















































<h1>Appendix</h1>

<h2>exceptions</h2>

<p>Brickyard provides some useful exceptions.</p>

................................................................................
&lt;&lt;class brickyard&gt;&gt;

&lt;&lt;exceptions&gt;&gt;

&lt;&lt;brickyard router interface&gt;&gt;

&lt;&lt;brickyard default router&gt;&gt;




</pre>


<h2>License</h2>

<pre id="license" title="license">
//I am not yet decided about license. But I prefer WTFPL. 
</pre>


</body></html>







|


>
>







 







|







 







|







 







>






|







 







<


<
>



|













>




|

|












|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>











5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
...
253
254
255
256
257
258
259

260
261

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
...
339
340
341
342
343
344
345

346
347
348
349
350
351
352
...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
...
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
	<title>Brickyard framework</title>
	<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>

<h1>Brickyard framework</h1>

<p>Because reinventing the wheel is fun.</p>

<p>It aims to be simpler and smaller than others. Not suitable for enterprise.</p>

<p>Note that source of this documentation is source of framework itself. </p>

<h2>Usage</h2>

<p>The usage is really simple. Minimal index.php file (an entry point and setup) look like this:</p>

<p>Firstly you need to include framework file and get one instance.</p>

................................................................................


<pre id="run" title="run">
ob_start();
</pre>


<p>Get from router current controller, method and it's arguments. Note that controller has <code>c_</code> prefix before it's class name.</p>


<pre id="run" title="run">
$controllerName = &quot;c_&quot; . $this-&gt;router-&gt;getController();
$methodName = $this-&gt;router-&gt;getMethod();
$args = $this-&gt;router-&gt;getArgs();
</pre>
................................................................................

<h3>Exception handling</h3>

<p>If framework is in develMode, we will show debug message.</p>


<pre id="exception handling" title="exception handling">
if ($this-&gt;inDevelMode){
    $this-&gt;bluescreen($e);
} else {
    &lt;&lt;detect type of exception&gt;&gt;
    &lt;&lt;show error message&gt;&gt;
}
</pre>

................................................................................
<p>But also in this case we need to check if error page is present.</p>


<pre id="show error message" title="show error message">
if (file_exists($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html')){
    ob_clean();
    echo file_get_contents($this-&gt;libPath . DIRECTORY_SEPARATOR . $err . '.html');
    exit; //to prevent more errors
}else{
    echo &quot;An error occured. Also error page is missing.&quot;;
}
</pre>


<h3>Bluescreen</h3>

<p>Before showing any debug message we will erase output.</p>


<pre id="bluescreen" title="bluescreen">
ob_clean();
</pre>
................................................................................


<pre id="init" title="init">
set_exception_handler(array($this,&quot;exception_handler&quot;));
</pre>



<h3>Default values</h3>


<p>Here follows some setting of framework.</p>


<pre id="defaults" title="defaults">
public $inDevelMode = false;
public $router = null;
public $libPath = '.';
public $indexPath = '.';
</pre>


<p>Some default instances are created in constructor.</p>


<pre id="defaults" title="defaults">
public function __construct(){
    $this-&gt;router = new brickyard_router_default;
    $this-&gt;libPath = dirname(__FILE__);
    $this-&gt;view = new brickyard_view_default(dirname(__FILE__) . DIRECTORY_SEPARATOR . &quot;tpl&quot;);
}
</pre>


<h3>Setters and getters</h3>

<p>Today we have setter and getter for router.</p>


<pre id="getters" title="getters">
public function getRouter()
{
    return $this-&gt;router;
}
</pre>



<pre id="setters" title="setters">
public function setRouter(brickyard_router_interface $router)
{
    $this-&gt;router = $router;
}
</pre>


<p>For views.</p>


<pre id="getters" title="getters">
public function getView()
{
    return $this-&gt;view;
}
</pre>



<pre id="setters" title="setters">
public function setView(brickyard_view_interface $view)
{
    $this-&gt;view = $view;
}
</pre>



<p>And for indexPath.</p>


<pre id="getters" title="getters">
public function getIndexPath()
................................................................................

<pre id="setters" title="setters">
public function setIndexPath($indexFilePath)
{
    $this-&gt;indexPath = dirname($indexFilePath);
}
</pre>



<h3>Brickyard class definition</h3>


<pre id="class brickyard" title="class brickyard">
class brickyard
................................................................................
interface brickyard_router_interface
{
    &lt;&lt;router interface code&gt;&gt;
}
</pre>


<p>We have an interface for router so default router can be changed to more complicated one.</p>


<pre id="router interface code" title="router interface code">
public function getController();
</pre>


................................................................................
            }
        }
        return $url;
    }
}
</pre>


<h2>Brickyard view</h2>

<p>In brickyard framework view is mean as template filler.</p>

<h2>Interface</h2>


<pre id="brickyard view interface" title="brickyard view interface">
interface brickyard_view_interface
{
    public function show($templateName, array $data);
}
</pre>


<p>Interface of view is very simple. It offers only one function called <code>show</code> which accepts template name as first parameter and associative array as second parameter. This function returns filled template.</p>

<h2>Implementation</h2>

<p>(Unexplained yet)</p>


<pre id="brickyard default view" title="brickyard default view">
class brickyard_view_default
{
    private $tplPath=&quot;tpl&quot;;

    function __construct($tplPath)
    {
        $this-&gt;tplPath = $tplPath;
    }

    public function show($tplName, array $data)
    {
        $tplFile = $this-&gt;tplPath . DIRECTORY_SEPARATOR . $tplName . &quot;.php&quot;;
        if (file_exists($tplFile)) {
            $data['view'] = $this;
            extract($data, EXTR_SKIP);
            ob_start();
            include $tplFile;
            $output = ob_get_contents();
            ob_end_clean();
            return $output;
        } else {
            throw new Exception('Template '.$tplName.' not found in file '.$tplFile);
        }
    }
}
</pre>


<h1>Appendix</h1>

<h2>exceptions</h2>

<p>Brickyard provides some useful exceptions.</p>

................................................................................
&lt;&lt;class brickyard&gt;&gt;

&lt;&lt;exceptions&gt;&gt;

&lt;&lt;brickyard router interface&gt;&gt;

&lt;&lt;brickyard default router&gt;&gt;

&lt;&lt;brickyard view interface&gt;&gt;

&lt;&lt;brickyard default view&gt;&gt;
</pre>


<h2>License</h2>

<pre id="license" title="license">
//I am not yet decided about license. But I prefer WTFPL. 
</pre>


</body></html>

Changes to brickyard.nw.

1
2
3
4
5


6
7
8
9
10
11
12
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
144
145
146
147
148
149
150

151
152
153
154
155
156
157
158
159
160
161
162
163
...
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215
216
217
218
219

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

















240
241
242
243
244
245
246
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
...
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
381
382
383
384
385
386
387















































388
389
390
391
392
393
394
...
425
426
427
428
429
430
431




432
433
434
435
436
437
# Brickyard framework

Yet another php framework.

It aims to be simpler and smaller than others. Not suitable for enterprise.



##Usage

The usage is really simple. Minimal index.php file (an entry point and setup) look like this:

Firstly you need to include framework file and get one instance.

................................................................................

It starts output control. It's useful for error pages.

<<run>>==
ob_start();
@

Get from router current controller, method and it's arguments. Note that controller has _c prefix before it's class name.

<<run>>==
$controllerName = "c_" . $this->router->getController();
$methodName = $this->router->getMethod();
$args = $this->router->getArgs();
@

................................................................................
@

###Exception handling

If framework is in develMode, we will show debug message.

<<exception handling>>==
if ($this->develMode){
	$this->bluescreen($e);
} else {
	<<detect type of exception>>
	<<show error message>>
}
@

................................................................................

But also in this case we need to check if error page is present.

<<show error message>>==
if (file_exists($this->libPath . DIRECTORY_SEPARATOR . $err . '.html')){
	ob_clean();
	echo file_get_contents($this->libPath . DIRECTORY_SEPARATOR . $err . '.html');

}else{
	echo "An error occured. Also error page is missing.";
}
@

##Bluescreen

Before showing any debug message we will erase output.

<<bluescreen>>==
ob_clean();
@

................................................................................

And exception handling.

<<init>>==
set_exception_handler(array($this,"exception_handler"));
@


###Default values

For now we are in devel mode permanently.


<<defaults>>==
public $develMode = false;
public $router = null;
public $libPath = '.';
public $indexPath = '.';
@

Some default instances are created in constructor.

<<defaults>>==
public function __construct(){
	$this->router = new brickyard_router_default;
	$this->libPath = dirname(__FILE__);

}
@

##Setters and getters

Today we have setter and getter or router.

<<getters>>==
public function getRouter()
{
	return $this->router;
}
@

<<setters>>==
public function setRouter($router)
{
	$this->router = $router;
}
@


















And for indexPath.

<<getters>>==
public function getIndexPath()
{
	return $this->indexPath;
................................................................................

<<setters>>==
public function setIndexPath($indexFilePath)
{
	$this->indexPath = dirname($indexFilePath);
}
@


###Brickyard class definition

<<class brickyard>>==
class brickyard
{
	<<defaults>>
................................................................................
<<brickyard router interface>>==
interface brickyard_router_interface
{
	<<router interface code>>
}
@

We have an interface for router. Later there will be setRouter function which will enable using of more complicated routers than default one.

<<router interface code>>==
public function getController();
@

Gets controller name or null if not known.

................................................................................
				}
			}
		}
		return $url;
	}
}
@
















































#Appendix

##exceptions

Brickyard provides some useful exceptions.

................................................................................
<<class brickyard>>

<<exceptions>>

<<brickyard router interface>>

<<brickyard default router>>




@

##License
<<license>>==
//I am not yet decided about license. But I prefer WTFPL. 
@


|


>
>







 







|







 







|







 







>





|







 







<


<
>


|











>



|

|









|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>






1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
198
199
200
201
202
203
204

205
206

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
...
269
270
271
272
273
274
275

276
277
278
279
280
281
282
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# Brickyard framework

Because reinventing the wheel is fun.

It aims to be simpler and smaller than others. Not suitable for enterprise.

Note that source of this documentation is source of framework itself. 

##Usage

The usage is really simple. Minimal index.php file (an entry point and setup) look like this:

Firstly you need to include framework file and get one instance.

................................................................................

It starts output control. It's useful for error pages.

<<run>>==
ob_start();
@

Get from router current controller, method and it's arguments. Note that controller has `c_` prefix before it's class name.

<<run>>==
$controllerName = "c_" . $this->router->getController();
$methodName = $this->router->getMethod();
$args = $this->router->getArgs();
@

................................................................................
@

###Exception handling

If framework is in develMode, we will show debug message.

<<exception handling>>==
if ($this->inDevelMode){
	$this->bluescreen($e);
} else {
	<<detect type of exception>>
	<<show error message>>
}
@

................................................................................

But also in this case we need to check if error page is present.

<<show error message>>==
if (file_exists($this->libPath . DIRECTORY_SEPARATOR . $err . '.html')){
	ob_clean();
	echo file_get_contents($this->libPath . DIRECTORY_SEPARATOR . $err . '.html');
	exit; //to prevent more errors
}else{
	echo "An error occured. Also error page is missing.";
}
@

###Bluescreen

Before showing any debug message we will erase output.

<<bluescreen>>==
ob_clean();
@

................................................................................

And exception handling.

<<init>>==
set_exception_handler(array($this,"exception_handler"));
@


###Default values


Here follows some setting of framework.

<<defaults>>==
public $inDevelMode = false;
public $router = null;
public $libPath = '.';
public $indexPath = '.';
@

Some default instances are created in constructor.

<<defaults>>==
public function __construct(){
	$this->router = new brickyard_router_default;
	$this->libPath = dirname(__FILE__);
	$this->view = new brickyard_view_default(dirname(__FILE__) . DIRECTORY_SEPARATOR . "tpl");
}
@

###Setters and getters

Today we have setter and getter for router.

<<getters>>==
public function getRouter()
{
	return $this->router;
}
@

<<setters>>==
public function setRouter(brickyard_router_interface $router)
{
	$this->router = $router;
}
@

For views.

<<getters>>==
public function getView()
{
	return $this->view;
}
@

<<setters>>==
public function setView(brickyard_view_interface $view)
{
	$this->view = $view;
}
@


And for indexPath.

<<getters>>==
public function getIndexPath()
{
	return $this->indexPath;
................................................................................

<<setters>>==
public function setIndexPath($indexFilePath)
{
	$this->indexPath = dirname($indexFilePath);
}
@


###Brickyard class definition

<<class brickyard>>==
class brickyard
{
	<<defaults>>
................................................................................
<<brickyard router interface>>==
interface brickyard_router_interface
{
	<<router interface code>>
}
@

We have an interface for router so default router can be changed to more complicated one.

<<router interface code>>==
public function getController();
@

Gets controller name or null if not known.

................................................................................
				}
			}
		}
		return $url;
	}
}
@

##Brickyard view

In brickyard framework view is mean as template filler.

##Interface

<<brickyard view interface>>==
interface brickyard_view_interface
{
	public function show($templateName, array $data);
}
@

Interface of view is very simple. It offers only one function called `show` which accepts template name as first parameter and associative array as second parameter. This function returns filled template.

##Implementation

(Unexplained yet)

<<brickyard default view>>==
class brickyard_view_default
{
	private $tplPath="tpl";
	
	function __construct($tplPath)
	{
		$this->tplPath = $tplPath;
	}
	
	public function show($tplName, array $data)
	{
		$tplFile = $this->tplPath . DIRECTORY_SEPARATOR . $tplName . ".php";
		if (file_exists($tplFile)) {
			$data['view'] = $this;
			extract($data, EXTR_SKIP);
			ob_start();
			include $tplFile;
			$output = ob_get_contents();
			ob_end_clean();
			return $output;
		} else {
			throw new Exception('Template '.$tplName.' not found in file '.$tplFile);
		}
	}
}
@

#Appendix

##exceptions

Brickyard provides some useful exceptions.

................................................................................
<<class brickyard>>

<<exceptions>>

<<brickyard router interface>>

<<brickyard default router>>

<<brickyard view interface>>

<<brickyard default view>>
@

##License
<<license>>==
//I am not yet decided about license. But I prefer WTFPL. 
@

Changes to brickyard.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19




20
21
22
23
24
25
26
27
28




29
30
31
32
33
34
35
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
...
226
227
228
229
230
231
232
233
234
235


























































<?php
//
// Brickyard framework by Severak
//
//I am not yet decided about license. But I prefer WTFPL.
class brickyard
{
	public $develMode = false;
	public $router = null;
	public $libPath = '.';
	public $indexPath = '.';
	public function __construct(){
		$this->router = new brickyard_router_default;
		$this->libPath = dirname(__FILE__);

	}
	
	public function getRouter()
	{
		return $this->router;




	}
	public function getIndexPath()
	{
		return $this->indexPath;
	}
	
	public function setRouter($router)
	{
		$this->router = $router;




	}
	public function setIndexPath($indexFilePath)
	{
		$this->indexPath = dirname($indexFilePath);
	}
	
	
................................................................................
	{
		throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
		
	}
	
	public function exception_handler($e)
	{
		if ($this->develMode){
			$this->bluescreen($e);
		} else {
			if ($e instanceof brickyard_exception_404){
				$err = 404;
			} elseif ($e instanceof brickyard_exception_403){
				$err = 403;
			} else {
				$err = 'error';
			}	
			
			if (file_exists($this->libPath . DIRECTORY_SEPARATOR . $err . '.html')){
				ob_clean();
				echo file_get_contents($this->libPath . DIRECTORY_SEPARATOR . $err . '.html');

			}else{
				echo "An error occured. Also error page is missing.";
			}
			
		}
		
	}
................................................................................

			}

		}

		return $url;

	}

}

































































|






>





>
>
>
>






|


>
>
>
>







 







|













>







 









|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
//
// Brickyard framework by Severak
//
//I am not yet decided about license. But I prefer WTFPL.
class brickyard
{
	public $inDevelMode = false;
	public $router = null;
	public $libPath = '.';
	public $indexPath = '.';
	public function __construct(){
		$this->router = new brickyard_router_default;
		$this->libPath = dirname(__FILE__);
		$this->view = new brickyard_view_default(dirname(__FILE__) . DIRECTORY_SEPARATOR . "tpl");
	}
	
	public function getRouter()
	{
		return $this->router;
	}
	public function getView()
	{
		return $this->view;
	}
	public function getIndexPath()
	{
		return $this->indexPath;
	}
	
	public function setRouter(brickyard_router_interface $router)
	{
		$this->router = $router;
	}
	public function setView(brickyard_view_interface $view)
	{
		$this->view = $view;
	}
	public function setIndexPath($indexFilePath)
	{
		$this->indexPath = dirname($indexFilePath);
	}
	
	
................................................................................
	{
		throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
		
	}
	
	public function exception_handler($e)
	{
		if ($this->inDevelMode){
			$this->bluescreen($e);
		} else {
			if ($e instanceof brickyard_exception_404){
				$err = 404;
			} elseif ($e instanceof brickyard_exception_403){
				$err = 403;
			} else {
				$err = 'error';
			}	
			
			if (file_exists($this->libPath . DIRECTORY_SEPARATOR . $err . '.html')){
				ob_clean();
				echo file_get_contents($this->libPath . DIRECTORY_SEPARATOR . $err . '.html');
				exit; //to prevent more errors
			}else{
				echo "An error occured. Also error page is missing.";
			}
			
		}
		
	}
................................................................................

			}

		}

		return $url;

	}

}

interface brickyard_view_interface

{

	public function show($templateName, array $data);

}

class brickyard_view_default

{

	private $tplPath="tpl";

	

	function __construct($tplPath)

	{

		$this->tplPath = $tplPath;

	}

	

	public function show($tplName, array $data)

	{

		$tplFile = $this->tplPath . DIRECTORY_SEPARATOR . $tplName . ".php";

		if (file_exists($tplFile)) {

			$data['view'] = $this;

			extract($data, EXTR_SKIP);

			ob_start();

			include $tplFile;

			$output = ob_get_contents();

			ob_end_clean();

			return $output;

		} else {

			throw new Exception('Template '.$tplName.' not found in file '.$tplFile);

		}

	}

}

Changes to c/demos.php.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
..
46
47
48
49
50
51
52
53












	}
	
	function index()
	{
		echo '<h1>Demos</h1>';
		echo '<ul>';
		echo '<li>' . $this->_getLink('exception handling', 'exceptions') . '</li>';

		echo '<li>' . $this->_getLink('source code brownser', 'source', array('c_demos', 'source')) . '</li>';
		echo '<li>' . $this->_getLink('this controller source', 'source', array('c_demos')) . '</li>';
		echo '</ul>';
	}
	
	function exceptions()
	{
................................................................................
				echo htmlspecialchars($file[$i]);
			}
			echo '</pre>';
		} else {
			throw new Exception("Class " . $controller . " is unreachable for source brownser.");
		}
	}
}



















>







 







|
>
>
>
>
>
>
>
>
>
>
>
>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
	}
	
	function index()
	{
		echo '<h1>Demos</h1>';
		echo '<ul>';
		echo '<li>' . $this->_getLink('exception handling', 'exceptions') . '</li>';
		echo '<li>' . $this->_getLink('view demo', 'view') . '</li>';
		echo '<li>' . $this->_getLink('source code brownser', 'source', array('c_demos', 'source')) . '</li>';
		echo '<li>' . $this->_getLink('this controller source', 'source', array('c_demos')) . '</li>';
		echo '</ul>';
	}
	
	function exceptions()
	{
................................................................................
				echo htmlspecialchars($file[$i]);
			}
			echo '</pre>';
		} else {
			throw new Exception("Class " . $controller . " is unreachable for source brownser.");
		}
	}
	
	function view()
	{
		echo $this->framework->getView()->show("test", array('a'=>'A'));
	}
	
	function __destruct()
	{
		echo '<hr>';
		$method = $this->framework->getRouter()->getMethod();
		echo 'see ' . $this->_getLink('source code', 'source', array('c_demos', $method));
	}
}

Changes to c/home.php.

1
2
3
4
5

6
7
<?php
class c_home{
	function index(){
		echo "<h1>It's working!</h1>";
		echo 'see some <a href="' .$this->framework->getRouter()->getLink('demos') . '">demos</a>';

	}
}





>


1
2
3
4
5
6
7
8
<?php
class c_home{
	function index(){
		echo "<h1>It's working!</h1>";
		echo 'see some <a href="' .$this->framework->getRouter()->getLink('demos') . '">demos</a>';
		echo ' or <a href="brickyard.html">annotated source code</a>';
	}
}

Deleted doc/index.txt.

1
ok
<


Added tpl/test.php.







>
>
>
1
2
3
<ul>
	<li>variable $a = <?php echo $a;?></li>
</ul>

Deleted v/wiki.php.

1
2
<h1><?php echo $title; ?></h1>
<?php echo $text; ?>
<
<