-
Notifications
You must be signed in to change notification settings - Fork 13
/
details.php
executable file
·157 lines (140 loc) · 4.56 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
<?php defined('BASEPATH') or exit('No direct script access allowed');
class Module_Faq extends Module
{
public $version = '1.0';
public function info()
{
return array(
'name' => array(
'en' => 'FAQ'
),
'description' => array(
'en' => 'Frequently Asked Questions'
),
'frontend' => true,
'backend' => true,
'menu' => 'content',
'sections' => array(
'faq' => array(
'name' => 'faq:faqs',
'uri' => 'admin/faq',
'shortcuts' => array(
'create' => array(
'name' => 'faq:new',
'uri' => 'admin/faq/create',
'class' => 'add'
)
)
),
'categories' => array(
'name' => 'faq:categories',
'uri' => 'admin/faq/categories/index',
'shortcuts' => array(
'create' => array(
'name' => 'faq:category:new',
'uri' => 'admin/faq/categories/create',
'class' => 'add'
)
)
)
)
);
}
/**
* Install
*
* This function will set up our
* FAQ/Category streams.
*/
public function install()
{
// We're using the streams API to
// do data setup.
$this->load->driver('Streams');
$this->load->language('faq/faq');
// Add faqs streams
if ( ! $this->streams->streams->add_stream('lang:faq:faqs', 'faqs', 'faq', 'faq_', null)) return false;
if ( ! $categories_stream_id = $this->streams->streams->add_stream('lang:faq:categories', 'categories', 'faq', 'faq_', null)) return false;
//$faq_categories
// Add some fields
$fields = array(
array(
'name' => 'Question',
'slug' => 'question',
'namespace' => 'faq',
'type' => 'text',
'extra' => array('max_length' => 200),
'assign' => 'faqs',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Answer',
'slug' => 'answer',
'namespace' => 'faq',
'type' => 'textarea',
'assign' => 'faqs',
'required' => true
),
array(
'name' => 'Title',
'slug' => 'faq_category_title',
'namespace' => 'faq',
'type' => 'text',
'assign' => 'categories',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Category',
'slug' => 'faq_category_select',
'namespace' => 'faq',
'type' => 'relationship',
'assign' => 'faqs',
'extra' => array('choose_stream' => $categories_stream_id)
)
);
$this->streams->fields->add_fields($fields);
$this->streams->streams->update_stream('faqs', 'faq', array(
'view_options' => array(
'id',
'question',
'answer',
'faq_category_select'
)
));
$this->streams->streams->update_stream('categories', 'faq', array(
'view_options' => array(
'id',
'faq_category_title'
)
));
return true;
}
/**
* Uninstall
*
* Uninstall our module - this should tear down
* all information associated with it.
*/
public function uninstall()
{
$this->load->driver('Streams');
// For this teardown we are using the simple remove_namespace
// utility in the Streams API Utilties driver.
$this->streams->utilities->remove_namespace('faq');
return true;
}
public function upgrade($old_version)
{
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.";
}
}