XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
layout.admin.model.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class layoutAdminModel extends layout
9 {
13  public function init()
14  {
15  }
16 
21  public function getLayoutAdminSetInfoView()
22  {
24 
25  Context::set('is_sitemap', '1');
26  $script = '<script src="./modules/layout/tpl/js/layout_modify.js"></script>';
27  $oTemplate = TemplateHandler::getInstance();
28  $html = $oTemplate->compile($this->module_path.'tpl/', 'layout_info_view');
29 
30  preg_match_all('/<!--#JSPLUGIN:(.*)-->/', $html, $m);
31  $pluginList = $m[1];
32 
33  foreach($pluginList as $plugin)
34  {
35  $info = Context::getJavascriptPluginInfo($plugin);
36  if(!$info)
37  {
38  continue;
39  }
40 
41  foreach($info->jsList as $js)
42  {
43  $script .= sprintf('<script src="%s"></script>', $js);
44  }
45  foreach($info->cssList as $css)
46  {
47  $csss .= sprintf('<link rel="stylesheet" href="%s" />', $css);
48  }
49  }
50 
51  $this->add('html', $csss . $script . $html);
52 
53  if($isReturn)
54  {
55  return $this->get('html');
56  }
57  }
58 
59  public function setLayoutAdminSetInfoView()
60  {
61  $layout_srl = Context::get('layout_srl');
62 
63  // Get layout information
64  $oLayoutModel = getModel('layout');
65  $layout_info = $oLayoutModel->getLayout($layout_srl);
66 
67  // Error appears if there is no layout information is registered
68  if(!$layout_info)
69  {
70  return $this->stop('msg_invalid_request');
71  }
72 
73  // Get a menu list
74  $oMenuAdminModel = getAdminModel('menu');
75  $menu_list = $oMenuAdminModel->getMenus();
76  Context::set('menu_list', $menu_list);
77 
78  $security = new Security();
79  $security->encodeHTML('menu_list..');
80 
81  $security = new Security($layout_info);
82  $layout_info = $security->encodeHTML('.', 'author..', 'extra_var..');
83 
84  $layout_info->description = nl2br(trim($layout_info->description));
85  if(!is_object($layout_info->extra_var))
86  {
87  $layout_info->extra_var = new StdClass();
88  }
89 
90  foreach($layout_info->extra_var as $var_name => $val)
91  {
92  if(isset($layout_info->{$var_name}->description))
93  {
94  $layout_info->{$var_name}->description = nl2br(trim($val->description));
95  }
96  }
97  Context::set('selected_layout', $layout_info);
98  }
99 
100  public function getLayoutAdminSetHTMLCSS()
101  {
102  // Set the layout with its information
103  $layout_srl = Context::get('layout_srl');
104  // Get layout information
105  $oLayoutModel = getModel('layout');
106  $layout_info = $oLayoutModel->getLayout($layout_srl);
107  // Error appears if there is no layout information is registered
108  if(!$layout_info)
109  {
110  return $this->dispLayoutAdminInstalledList();
111  }
112 
113  // Get Layout Code
114  if($oLayoutModel->useDefaultLayout($layout_info->layout_srl))
115  {
116  $layout_file = $oLayoutModel->getDefaultLayoutHtml($layout_info->layout);
117  $layout_css_file = $oLayoutModel->getDefaultLayoutCss($layout_info->layout);
118  }
119  else
120  {
121  $layout_file = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
122  $layout_css_file = $oLayoutModel->getUserLayoutCss($layout_info->layout_srl);
123 
124  if(!file_exists($layout_file)) $layout_file = $layout_info->path . 'layout.html';
125  if(!file_exists($layout_css_file)) $layout_css_file = $layout_info->path . 'layout.css';
126  }
127 
128  if(file_exists($layout_css_file))
129  {
130  $layout_code_css = FileHandler::readFile($layout_css_file);
131  Context::set('layout_code_css', $layout_code_css);
132  }
133 
134  $layout_code = FileHandler::readFile($layout_file);
135  Context::set('layout_code', $layout_code);
136 
137  // set User Images
138  $layout_image_list = $oLayoutModel->getUserLayoutImageList($layout_info->layout_srl);
139  Context::set('layout_image_list', $layout_image_list);
140 
141  $layout_image_path = $oLayoutModel->getUserLayoutImagePath($layout_info->layout_srl);
142  Context::set('layout_image_path', $layout_image_path);
143  // Set widget list
144  $oWidgetModel = getModel('widget');
145  $widget_list = $oWidgetModel->getDownloadedWidgetList();
146  Context::set('widget_list', $widget_list);
147 
148  $security = new Security($layout_info);
149  $layout_info = $security->encodeHTML('.', '.author..');
150  Context::set('selected_layout', $layout_info);
151 
152  //Security
153  $security = new Security();
154  $security->encodeHTML('layout_list..');
155  $security->encodeHTML('layout_list..author..');
156 
157  $security = new Security();
158  $security->encodeHTML('layout_code_css', 'layout_code', 'widget_list..title');
159 
160  $script = '<script src="./modules/layout/tpl/js/layout_admin_set_html.js"></script>';
161  $oTemplate = &TemplateHandler::getInstance();
162  $html = $oTemplate->compile($this->module_path.'tpl/', 'layout_html_css_view');
163 
164  $this->add('html', $script.$html);
165  }
166 
168  {
169  $siteSrl = Context::get('site_srl');
170  $type = Context::get('type');
171 
172  $layoutSrl = $this->getSiteDefaultLayout($type, $siteSrl);
173 
174  $oLayoutModel = getModel('layout');
175  $layoutInfo = $oLayoutModel->getLayoutRawData($layoutSrl, array('title'));
176 
177  $this->add('layout_srl', $layoutSrl);
178  $this->add('title', $layoutInfo->title);
179  }
180 
181  public function getSiteDefaultLayout($viewType = 'P', $siteSrl = 0)
182  {
183  $target = ($viewType == 'M') ? 'mlayout_srl' : 'layout_srl';
184  $designInfoFile = sprintf(_XE_PATH_ . 'files/site_design/design_%s.php', $siteSrl);
185  if(FileHandler::exists($designInfoFile)) include($designInfoFile);
186 
187  if(!$designInfo || !$designInfo->{$target})
188  {
189  return 0;
190  }
191 
192  $oModel = getModel('layout');
193  $layout_info = $oModel->getLayout($designInfo->{$target});
194 
195  if(!$layout_info)
196  {
197  return 0;
198  }
199 
200  return $designInfo->{$target};
201  }
202 }
203 /* End of file layout.admin.model.php */
204 /* Location: ./modules/layout/layout.admin.model.php */
$designInfo
Definition: ko.install.php:221
add($key, $val)
getSiteDefaultLayout($viewType= 'P', $siteSrl=0)
$layout_srl
Definition: ko.install.php:186
set($key, $val, $set_to_get_vars=0)
getAdminModel($module_name)
Definition: func.inc.php:156
const _XE_PATH_
Definition: config.inc.php:49
readFile($filename)
getJavascriptPluginInfo($pluginName)
getModel($module_name)
Definition: func.inc.php:145