XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
ko.install.php
Go to the documentation of this file.
1 <?php
2 
3 // ko/en/...
5 $logged_info = Context::get('logged_info');
6 
8 
9 // sitemap
10 $sitemap = array(
11  'GNB' => array(
12  'title' => 'Main menu',
13  'list' => array(
14  array(
15  'menu_name' => 'Welcome Page',
16  'module_type' => 'WIDGET',
17  'module_id' => 'index',
18  ),
19  array(
20  'menu_name' => 'Board',
21  'module_type' => 'board',
22  'module_id' => 'board',
23  'list' => array(
24  array(
25  'menu_name' => 'SAMPLE 1',
26  'is_shortcut' => 'Y',
27  'shortcut_target' => '#',
28  'list' => array(
29  array(
30  'menu_name' => 'SAMPLE 1-1',
31  'is_shortcut' => 'Y',
32  'shortcut_target' => '#'
33  ),
34  )
35  ),
36  array(
37  'menu_name' => 'SAMPLE 2',
38  'is_shortcut' => 'Y',
39  'shortcut_target' => '#'
40  ),
41  array(
42  'menu_name' => 'SAMPLE 3',
43  'is_shortcut' => 'Y',
44  'shortcut_target' => '#'
45  ),
46  )
47  ),
48  array(
49  'menu_name' => 'XEIcon',
50  'module_type' => 'WIDGET',
51  'module_id' => 'xeicon',
52  ),
53  )
54  ),
55  'UNB' => array(
56  'title' => 'Utility menu',
57  'list' => array(
58  array(
59  'menu_name' => 'XE Official Site',
60  'is_shortcut' => 'Y',
61  'open_window' => 'Y',
62  'shortcut_target' => 'http://www.xpressengine.com'
63  ),
64  array(
65  'menu_name' => 'GitHub',
66  'is_shortcut' => 'Y',
67  'open_window' => 'Y',
68  'shortcut_target' => 'https://github.com/xpressengine'
69  ),
70  )
71  ),
72  'FNB' => array(
73  'title' => 'Footer Menu',
74  'list' => array(
75  array(
76  'menu_name' => 'Welcome Page',
77  'is_shortcut' => 'Y',
78  'shortcut_target' => 'index',
79  'list' => array(
80  array(
81  'menu_name' => 'SAMPLE 1',
82  'is_shortcut' => 'Y',
83  'shortcut_target' => '#'
84  ),
85  array(
86  'menu_name' => 'SAMPLE 2',
87  'is_shortcut' => 'Y',
88  'shortcut_target' => '#'
89  ),
90  array(
91  'menu_name' => 'SAMPLE 3',
92  'is_shortcut' => 'Y',
93  'shortcut_target' => '#'
94  )
95  ),
96  ),
97  array(
98  'menu_name' => 'Board',
99  'is_shortcut' => 'Y',
100  'shortcut_target' => 'board',
101  'list' => array(
102  array(
103  'menu_name' => 'SAMPLE 1',
104  'is_shortcut' => 'Y',
105  'shortcut_target' => '#'
106  ),
107  array(
108  'menu_name' => 'SAMPLE 2',
109  'is_shortcut' => 'Y',
110  'shortcut_target' => '#'
111  )
112  )
113  ),
114  array(
115  'menu_name' => 'XEIcon',
116  'is_shortcut' => 'Y',
117  'shortcut_target' => 'xeicon',
118  'list' => array(
119  array(
120  'menu_name' => 'SAMPLE 1',
121  'is_shortcut' => 'Y',
122  'shortcut_target' => '#'
123  )
124  )
125  ),
126  ),
127  ),
128 );
129 
130 function __makeMenu(&$list, $parent_srl)
131 {
133  foreach($list as $idx => &$item)
134  {
135  Context::set('parent_srl', $parent_srl, TRUE);
136  Context::set('menu_name', $item['menu_name'], TRUE);
137  Context::set('module_type', $item['module_type'], TRUE);
138  Context::set('module_id', $item['module_id'], TRUE);
139  if($item['is_shortcut'] === 'Y')
140  {
141  Context::set('is_shortcut', $item['is_shortcut'], TRUE);
142  Context::set('shortcut_target', $item['shortcut_target'], TRUE);
143  }
144  else
145  {
146  Context::set('is_shortcut', 'N', TRUE);
147  Context::set('shortcut_target', null, TRUE);
148  }
149 
150  $output = $oMenuAdminController->procMenuAdminInsertItem();
151  if($output instanceof BaseObject && !$output->toBool())
152  {
153  return $output;
154  }
155  $menu_srl = $oMenuAdminController->get('menu_item_srl');
156  $item['menu_srl'] = $menu_srl;
157 
158  if($item['list']) __makeMenu($item['list'], $menu_srl);
159  }
160 }
161 
162 
163 // 사이트맵 생성
164 foreach($sitemap as $id => &$val)
165 {
166  $output = $oMenuAdminController->addMenu($val['title']);
167  if(!$output->toBool())
168  {
169  return $output;
170  }
171  $val['menu_srl'] = $output->get('menuSrl');
172 
173  __makeMenu($val['list'], $val['menu_srl']);
174 
175  $oMenuAdminController->makeHomemenuCacheFile($val['menu_srl']);
176 }
177 
178 // create Layout
179 //extra_vars init
180 $extra_vars = new stdClass();
181 $extra_vars->GNB = $sitemap['GNB']['menu_srl'];
182 $extra_vars->UNB = $sitemap['UNB']['menu_srl'];
183 $extra_vars->FNB = $sitemap['FNB']['menu_srl'];
184 
185 $args = new stdClass();
187 $args->site_srl = 0;
188 $args->layout = 'xedition';
189 $args->title = 'XEDITION';
190 $args->layout_type = 'P';
191 
194 if(!$output->toBool()) return $output;
195 
196 // update Layout (PC)
197 $args->extra_vars = serialize($extra_vars);
198 $output = $oLayoutAdminController->updateLayout($args);
199 if(!$output->toBool()) return $output;
200 
201 //create mobile layout
203 $args->layout = 'default';
204 $args->title = 'welcome_mobile_layout';
205 $args->layout_type = 'M';
206 $extra_vars->main_menu = $sitemap['GNB']['menu_srl'];
207 
208 $output = $oLayoutAdminController->insertLayout($args);
209 if(!$output->toBool()) return $output;
210 
211 // update mobile Layout
212 $args->extra_vars = serialize($extra_vars);
213 $output = $oLayoutAdminController->updateLayout($args);
214 if(!$output->toBool()) return $output;
215 
216 
217 $siteDesignPath = _XE_PATH_.'files/site_design/';
219 
220 
221 $designInfo = new stdClass();
222 $designInfo->layout_srl = $layout_srl;
223 $designInfo->mlayout_srl = $mlayout_srl;
224 
225 $moduleList = array('page', 'board', 'editor');
226 $moutput = ModuleHandler::triggerCall('menu.getModuleListInSitemap', 'after', $moduleList);
227 if($moutput->toBool())
228 {
229  $moduleList = array_unique($moduleList);
230 }
231 
232 $skinTypes = array('skin'=>'skins/', 'mskin'=>'m.skins/');
233 
234 $designInfo->module = new stdClass();
235 
236 $oModuleModel = getModel('module'); /* @var $oModuleModel moduleModel */
237 foreach($skinTypes as $key => $dir)
238 {
239  $skinType = $key == 'skin' ? 'P' : 'M';
240  foreach($moduleList as $moduleName)
241  {
242  $designInfo->module->{$moduleName} = new stdClass();
243  $designInfo->module->{$moduleName}->{$key} = $oModuleModel->getModuleDefaultSkin($moduleName, $skinType, 0, false);
244  }
245 }
246 $designInfo->module->board->skin = 'xedition';
247 $designInfo->module->editor->skin = 'ckeditor';
248 
249 $oAdminController = getAdminController('admin'); /* @var $oAdminController adminAdminController */
250 $oAdminController->makeDefaultDesignFile($designInfo, 0);
251 
252 // create page content
253 $moduleInfo = $oModuleModel->getModuleInfoByMenuItemSrl($sitemap['GNB']['list'][0]['menu_srl']);
254 $module_srl = $moduleInfo->module_srl;
255 
256 // insert PageContents - widget
258 
259 $oDocumentModel = getModel('document'); /* @var $oDocumentModel documentModel */
260 $oDocumentController = getController('document'); /* @var $oDocumentController documentController */
261 
262 $obj = new stdClass();
263 
264 $obj->member_srl = $logged_info->member_srl;
265 $obj->user_id = htmlspecialchars_decode($logged_info->user_id);
266 $obj->user_name = htmlspecialchars_decode($logged_info->user_name);
267 $obj->nick_name = htmlspecialchars_decode($logged_info->nick_name);
268 $obj->email_address = $logged_info->email_address;
269 
270 $obj->module_srl = $module_srl;
271 Context::set('version', __XE_VERSION__);
272 $obj->title = 'Welcome XE';
273 
274 $obj->content = $oTemplateHandler->compile(_XE_PATH_ . 'modules/install/script/welcome_content', 'welcome_content_'.$lang);
275 
276 $output = $oDocumentController->insertDocument($obj, true);
277 if(!$output->toBool()) return $output;
278 
279 $document_srl = $output->get('document_srl');
280 
281 unset($obj->document_srl);
282 $obj->title = 'Welcome mobile XE';
283 $output = $oDocumentController->insertDocument($obj, true);
284 if(!$output->toBool()) return $output;
285 
286 // save PageWidget
287 $oModuleController = getController('module'); /* @var $oModuleController moduleController */
288 $mdocument_srl = $output->get('document_srl');
289 $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
290 $module_info->content = '<img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="width: 100%; float: left;" body="" document_srl="'.$document_srl.'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" />';
291 $module_info->mcontent = '<img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="width: 100%; float: left;" body="" document_srl="'.$mdocument_srl.'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" />';
292 $output = $oModuleController->updateModule($module_info);
293 if(!$output->toBool()) return $output;
294 
295 // insertFirstModule
296 $site_args = new stdClass();
297 $site_args->site_srl = 0;
298 $site_args->index_module_srl = $module_srl;
299 $oModuleController->updateSite($site_args);
300 
301 
302 // XEIcon page
303 $moduleInfo = $oModuleModel->getModuleInfoByMenuItemSrl($sitemap['GNB']['list'][2]['menu_srl']);
305 
307 for($i = 1; $i <=4; $i++)
308 {
309  unset($obj->document_srl);
310  $obj->title = "XEIcon ({$i})";
311  $obj->content = $oTemplateHandler->compile(_XE_PATH_ . 'modules/install/script/xeicon_content', 'xeicon_content_ko_' . $i);
312 
313  $output = $oDocumentController->insertDocument($obj, true);
314  if(!$output->toBool()) return $output;
315 
316  $xeicon_document_srl[$i] = $output->get('document_srl');
317 }
318 
319 // save PageWidget
320 $oModuleController = getController('module'); /* @var $oModuleController moduleController */
321 $module_info = $oModuleModel->getModuleInfoByModuleSrl($xeicon_module_srl);
322 $module_info->content = '<div widget="widgetBox" style="float:left;width:100%;" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" css_class="XEicon" ><div><div><img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="float:left;padding:none;margin:none;width:100%;" document_srl="'.$xeicon_document_srl[1].'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" /><img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="float:left;padding:none;margin:none;width:100%;" document_srl="'.$xeicon_document_srl[2].'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" /><img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="float:left;padding:none;margin:none;width:100%;" document_srl="'.$xeicon_document_srl[3].'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" /><img hasContent="true" class="zbxe_widget_output" widget="widgetContent" style="float:left;padding:none;margin:none;width:100%;" document_srl="'.$xeicon_document_srl[4].'" widget_padding_left="0" widget_padding_right="0" widget_padding_top="0" widget_padding_bottom="0" /></div></div></div>';
323 $output = $oModuleController->updateModule($module_info);
324 if(!$output->toBool()) return $output;
325 
326 
327 // create menu cache
328 $oMenuAdminController->makeXmlFile($menuSrl);
329 
330 /* End of file ko.install.php */
$oModuleModel
Definition: ko.install.php:236
$designInfo
Definition: ko.install.php:221
getController($module_name)
Definition: func.inc.php:90
$oMenuAdminController
Definition: ko.install.php:7
$xeicon_document_srl
Definition: ko.install.php:306
const __XE_VERSION__
Definition: config.inc.php:32
$obj
Definition: ko.install.php:262
if($moutput->toBool()) $skinTypes
Definition: ko.install.php:232
$output
Definition: ko.install.php:193
$module_info
Definition: ko.install.php:289
foreach($sitemap as $id=> &$val) $extra_vars
Definition: ko.install.php:180
$layout_srl
Definition: ko.install.php:186
set($key, $val, $set_to_get_vars=0)
$oTemplateHandler
Definition: ko.install.php:257
$oLayoutAdminController
Definition: ko.install.php:192
$moduleList
Definition: ko.install.php:225
$mdocument_srl
Definition: ko.install.php:288
$args
Definition: ko.install.php:185
__makeMenu(&$list, $parent_srl)
Definition: ko.install.php:130
$siteDesignPath
Definition: ko.install.php:217
$document_srl
Definition: ko.install.php:279
$moutput
Definition: ko.install.php:226
$oDocumentModel
Definition: ko.install.php:259
makeDir($path_string)
const _XE_PATH_
Definition: config.inc.php:49
$moduleInfo
Definition: ko.install.php:253
$oDocumentController
Definition: ko.install.php:260
getNextSequence()
Definition: func.inc.php:236
$xeicon_module_srl
Definition: ko.install.php:304
getModel($module_name)
Definition: func.inc.php:145
$oAdminController
Definition: ko.install.php:249
getAdminController($module_name)
Definition: func.inc.php:101
$module_srl
Definition: ko.install.php:254
$oModuleController
Definition: ko.install.php:287
$sitemap
Definition: ko.install.php:10
triggerCall($trigger_name, $called_position, &$obj)
$mlayout_srl
Definition: ko.install.php:202
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23
$site_args
Definition: ko.install.php:296