-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.php
115 lines (94 loc) · 3.78 KB
/
sample.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
use DataHandle\Config;
use DataHandle\Session;
use DataHandle\Request;
class Sample extends \View\Layout
{
public function __construct()
{
parent::__construct();
Config::set('response', 'content');
\View\View::setDom($this);
}
public function onCreate()
{
parent::onCreate();
if (Session::get('user'))
{
$this->onLogged();
}
else
{
$this->onLogin();
}
}
public function onLogged()
{
$this->setLayoutFile('page\base');
$this->addCssJs();
$nav = $this->getElementsByTagName('nav')->item(0);
$nav = new View\DomContainer($nav);
$submenu['home-main'] = '<i class="fa fa-user"> </i>Main';
$submenu['home-cliente'] = '<i class="fa fa-user"> </i>Cliente';
$submenu['example-example'] = '<i class="fa fa-user"> </i>Example';
$submenu['example-example/event/pk'] = '<i class="fa fa-user"> </i>Example 2';
$submenu['home-main/sair'] = '<i class="fa fa-sign-out"> </i>Sair';
$modules['submenu'] = array('<i class="fa fa-user"> </i>Sub-menu', $submenu);
$nav->append(new \View\Ext\Menu('menuzao', $modules));
}
public function onLogin()
{
$this->setLayoutFile('page\login');
$this->addCssJs();
$this->addStyleShet('loginstyle', 'assets/login.css');
$this->byId('user')->setValue(Request::get('user'));
if (Request::get('login') !== NULL)
{
$this->login(Request::get('user'), Request::get('password'));
}
$this->setBaseUrl();
}
public function addCssJs()
{
$optimizer = new \Misc\Optimizer(\Disk\File::getFromStorage('sample.js')); //, '\Misc\JsMin');
$optimizer->addFile(BLEND_PATH . '/js/jquery.min.js');
$optimizer->addFile(BLEND_PATH . '/js/blend.js');
$optimizer->addFile(BLEND_PATH . '/js/jquery.autonumeric.js');
$optimizer->addFile(BLEND_PATH . '/js/jquery.mask.js');
$optimizer->addFile(BLEND_PATH . '/js/jquery.datetimepicker.js');
$optimizer->addFile(BLEND_PATH . '/js/shortcut.js');
$optimizer->addFile(BLEND_PATH . '/js/blend.js');
$optimizer->addFile(BLEND_PATH . '/js/shortcut.js');
$optimizer->addFile(BLEND_PATH . '/js/blend/popup.js');
$optimizer->addFile(BLEND_PATH . '/js/blend/menu.js');
$optimizer->addFile(BLEND_PATH . '/js/blend/cookie.js');
$optimizer->addFile(BLEND_PATH . '/js/plugin/blend.lazyloading.js');
$optimizer->addFile(BLEND_PATH . '/js/plugin/blend.convertajaxlinks.js');
$optimizer->addFile(BLEND_PATH . '/js/plugin/blend.onpressenter.js');
$optimizer->addFile(BLEND_PATH . '/js/slide.js');
foreach (\Disk\File::find(BLEND_PATH . '/js/blend/*.js') as $fileJs)
{
$optimizer->addFile($fileJs);
}
$optimizer->addFile(BLEND_PATH . '/js/plugin/blend.grownumber.js');
$optimizer->addFile(BLEND_PATH . '/js/dropzone.js');
$output = $optimizer->execute();
$script = new \View\Script($output->getUrl(), null, \View\Script::TYPE_JAVASCRIPT, false);
$this->getHtml()->appendChild($script);
$this->addStyleShet('base', BLEND_PATH . '/base.css', NULL, FALSE);
$this->addStyleShet('main', 'assets/sample.css');
$this->addStyleShet('fontawesome', 'assets/font-awesome.min.css');
}
protected function login($user, $password)
{
if (!$user || !$password)
{
$this->byId('error')->show();
}
else
{
Session::set('user', 1);
\App::refresh();
}
}
}