-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdmin.php
More file actions
66 lines (54 loc) · 1.46 KB
/
Admin.php
File metadata and controls
66 lines (54 loc) · 1.46 KB
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
<?php
namespace WebFace;
use \Silex\Application;
/**
*
*/
class Admin
{
protected $app = null;
protected $navigation = array();
protected $tableNames = array();
protected $currentTable = null;
public function __construct(Application $app, $navigation, $tableNames)
{
$this->app = $app;
$this->navigation = $navigation;
$this->tableNames = $tableNames;
}
public function getNavigation()
{
return $this->navigation;
}
public function setCurrentTable($table)
{
$this->app['webface.admin.current_service_container']->setCurrentTable($table);
$this->currentTable = $table;
foreach ($this->navigation as $group => &$pages) {
foreach ($pages as &$page) {
if ($table == $page['table']) {
$page['active'] = true;
break 2;
}
}
}
}
public function getCurrentTable()
{
return $this->currentTable;
}
public function getCurrentTableLabel()
{
return $this->tableNames[$this->currentTable];
}
public function generateRandomString($length = 10)
{
$result = '';
$alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$alphaLength = strlen($alpha);
for ($i = 0; $i < $length; $i++) {
$result .= $alpha[rand(0, $alphaLength - 1)];
}
return $result;
}
}