-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdetails.php
207 lines (190 loc) · 6.48 KB
/
details.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php defined('BASEPATH') or exit('No direct script access allowed');
class Module_Banners extends Module
{
public $version = '1.0';
public function info()
{
return array(
'name' => array(
'en' => 'Banners',
'zh' => '廣告看板'
),
'description' => array(
'en' => 'Manage different banners on your site.',
'zh' => '管理網站中各式各樣的廣告看板。'
),
'frontend' => false,
'backend' => true,
'menu' => 'content',
/* 'shortcuts' => array(
'create' => array(
'name' => 'banner:new',
'uri' => 'admin/banners/create',
'class' => 'add'
)
), */
'sections' => array(
'banners' => array(
'name' => 'banner:banners',
'uri' => 'admin/banners',
'shortcuts' => array(
array(
'name' => 'banner:new',
'uri' => 'admin/banners/create',
'class' => 'add'
),
),
),
'groups' => array(
'name' => 'group:groups',
'uri' => 'admin/banners/groups',
'shortcuts' => array(
array(
'name' => 'group:new',
'uri' => 'admin/banners/groups/create',
'class' => 'add'
)
)
)
)
);
}
public function install()
{
// We're using the streams API to
// do data setup.
$this->load->driver('Streams');
$this->load->language('banners/banners');
$this->load->language('banners/groups');
// Add banners streams
if ( ! $this->streams->streams->add_stream(lang('banner:banners'), 'banners', 'banner', 'banner_', null)) return false;
// Add groups streams
if ( ! $this->streams->streams->add_stream(lang('group:groups'), 'groups', 'banner', 'banner_', null)) return false;
// Add some fields
$fields = array(
// For banners stream
array(
'name' => 'Group',
'slug' => 'group',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'relationship',
'extra' => array(
'choose_stream' => $this->streams->streams->get_stream('groups', 'banner')->id
),
'required' => true
),
array(
'name' => 'Status',
'slug' => 'status',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'choice',
'extra' => array(
'max_length' => 1,
'default_value' => '0',
'choice_type' => 'dropdown',
'choice_data' => "0 : lang:banner:draft\n1 : lang:banner:live"
),
'required' => true
),
array(
'name' => 'Title',
'slug' => 'title',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'text',
'extra' => array('max_length' => 200),
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Description',
'slug' => 'description',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'textarea',
'required' => false
),
array(
'name' => 'URL',
'slug' => 'url',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'url',
'required' => true
),
array(
'name' => 'Start Date',
'slug' => 'start_date',
'namespace' => 'banner',
'type' => 'datetime',
'assign' => 'banners',
// error occurred without input_type when create new banner, don't know why.
'extra' => array('use_time'=>'yes', 'storage'=>'unix', 'input_type'=>'datepicker'),
'required' => true,
'unique' => false
),
array(
'name' => 'End Date',
'slug' => 'end_date',
'namespace' => 'banner',
'type' => 'datetime',
'assign' => 'banners',
'extra' => array('use_time'=>'yes', 'storage'=>'unix', 'input_type'=>'datepicker'),
'required' => true,
'unique' => false
),
array(
'name' => 'Image file',
'slug' => 'image_file',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'image',
'extra' => array('folder'=>3, 'allowed_types'=>'jpg|gif|png'),
'required' => true
),
// For groups stream
array(
'name' => 'Title',
'slug' => 'group_title',
'namespace' => 'banner',
'assign' => 'groups',
'type' => 'text',
'extra' => array('max_length'=>200),
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Slug',
'slug' => 'group_slug',
'namespace' => 'banner',
'assign' => 'groups',
'type' => 'slug',
'extra' => array('space_type' => '-', 'slug_field' => 'group_title'),
'required' => true
)
);
$this->streams->fields->add_fields($fields);
return true;
}
public function uninstall()
{
$this->load->driver('Streams');
$this->streams->utilities->remove_namespace('banner');
return true;
}
public function upgrade($old_version)
{
// Your Upgrade Logic
return true;
}
public function help()
{
// Return a string containing help info
// You could include a file and return it here.
return "No documentation has been added for this module.<br />Contact the module developer for assistance.";
}
}