-
Notifications
You must be signed in to change notification settings - Fork 1
/
Factory.php
70 lines (57 loc) · 1.41 KB
/
Factory.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
<?php
/**
* @package CMS\Factory
*/
class CMS_Factory implements Core_ModuleInterface
{
static $name = 'CMSComponentFactory';
static $admin_menu_title = 'Фабрика';
static function initialize($config = array())
{
foreach ($config as $key => $value)
self::$$key = $value;
CMS::add_component(self::$name, new CMS_Factory_Mapper());
CMS_Admin::menu(self::$admin_menu_title, CMS::admin_path('factory'), 'puzzle.png');
}
}
class CMS_Factory_Mapper extends CMS_Mapper
{
public function controllers()
{
return array(
'CMS.Controller.Factory' => array(
'path' => '{admin:factory}',
'rules' => array(
'{^$}' => array('action' => 'index'),
'{^([^/]+)/$}' => array('{1}', false, 'action' => 'table'),
'{^([^/]+)/(schema|orm|admin)/$}' => array('{1}', '{2}', 'action' => 'table'),
'{^([^/]+)/(component)/$}' => array('{1}', '{2}', 'action' => '{2}'),
),
),
);
}
public function index_url()
{
return CMS::admin_path('factory');
}
public function table_url($table)
{
return CMS::admin_path("factory/{$table}");
}
public function orm_url($table)
{
return $this->table_url($table) . 'orm/';
}
public function admin_url($table)
{
return $this->table_url($table) . 'admin/';
}
public function schema_url($table)
{
return $this->table_url($table) . 'schema/';
}
public function component_url($table)
{
return $this->table_url($table) . 'component/';
}
}