/
app.class.php
76 lines (64 loc) · 1.26 KB
/
app.class.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
<?php
/**
* Application
* ----
*/
class NyaaFWApp extends NyaaStore
{
protected $FW;
function __construct( $fw )
{
$this->FW = $fw;
}
function getTemplater( )
{
$Tpl = $this->FW->getTemplater( );
$Tpl->set('request',$this->Request->get());
return $Tpl;
}
function init( )
{
}
function setRequest( $Req )
{
$this->Request = $Req;
}
function run( )
{
$tpl = $this->myName.'.html';
return $this->getTemplater( )->fetch($tpl);
}
function formFactory( $conf, $key )
{
require_once 'form/form.class.php';
$form = new NyaaForm( );
$form->loadFile($conf);
$form->addHidden('__FORM_ID__', $key);
return $form;
}
function validaterFactory( $conf )
{
require_once 'validater/validate.class.php';
require_once 'validater/validater.class.php';
$conf = NyaaConf::load( $conf );
$validater = new NyaaValidater( );
foreach($conf->get( ) as $k=>$v)
{
$validate = NyaaValidate::factory(
array(
'type' => $v['type'],
'target' => $v['target'],
'message' => $v['message'],
'con' => $v['message_sep']
)
);
$validater->addValidate( $validate );
}
return $validater;
}
function doSnippet( $method, $option )
{
return call_user_func( array($this,'snip'.ucfirst($method)), $option);
}
}
?>