XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
page.mobile.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 require_once(_XE_PATH_.'modules/page/page.view.php');
4 
5 class pageMobile extends pageView
6 {
7  function init()
8  {
9  // Get a template path (page in the administrative template tpl putting together)
10  $this->setTemplatePath($this->module_path.'tpl');
11 
12  switch($this->module_info->page_type)
13  {
14  case 'WIDGET' :
15  {
16  $this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
17  $this->interval = (int)($this->module_info->page_caching_interval);
18  break;
19  }
20  case 'OUTSIDE' :
21  {
22  $this->cache_file = sprintf("./files/cache/opage/%d.%s.m.cache.php", $this->module_info->module_srl, Context::getSslStatus());
23  $this->interval = (int)($this->module_info->page_caching_interval);
24  $this->path = $this->module_info->mpath;
25  break;
26  }
27  }
28  }
29 
30  function dispPageIndex()
31  {
32  // Variables used in the template Context:: set()
33  if($this->module_srl) Context::set('module_srl',$this->module_srl);
34 
35  $page_type_name = strtolower($this->module_info->page_type);
36  $method = '_get' . ucfirst($page_type_name) . 'Content';
37  if (method_exists($this, $method)) $page_content = $this->{$method}();
38  else return new BaseObject(-1, sprintf('%s method is not exists', $method));
39 
40  Context::set('module_info', $this->module_info);
41  Context::set('page_content', $page_content);
42 
43  $this->setTemplateFile('mobile');
44  }
45 
46  function _getWidgetContent()
47  {
48  // Arrange a widget ryeolro
49  if($this->module_info->mcontent)
50  {
51  $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
52  $interval = (int)($this->module_info->page_caching_interval);
53  if($interval>0)
54  {
55  if(!file_exists($cache_file) || filesize($cache_file) < 1)
56  {
57  $mtime = 0;
58  }
59  else
60  {
61  $mtime = filemtime($cache_file);
62  }
63 
64  if($mtime + $interval*60 > $_SERVER['REQUEST_TIME'])
65  {
66  $page_content = FileHandler::readFile($cache_file);
67  $page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content);
68  }
69  else
70  {
71  $oWidgetController = getController('widget');
72  $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
73  FileHandler::writeFile($cache_file, $page_content);
74  }
75  }
76  else
77  {
78  if(file_exists($cache_file))
79  {
81  }
82  $page_content = $this->module_info->mcontent;
83  }
84  }
85  else
86  {
87  $page_content = $this->module_info->content;
88  }
89 
90  return $page_content;
91  }
92 
93  function _getArticleContent()
94  {
95  $oTemplate = &TemplateHandler::getInstance();
96 
97  $oDocumentModel = getModel('document');
98  $oDocument = $oDocumentModel->getDocument(0, true);
99 
100  if($this->module_info->mdocument_srl)
101  {
102  $document_srl = $this->module_info->mdocument_srl;
103  $oDocument->setDocument($document_srl);
104  Context::set('document_srl', $document_srl);
105  }
106  if(!$oDocument->isExists())
107  {
108  $document_srl = $this->module_info->document_srl;
109  $oDocument->setDocument($document_srl);
110  Context::set('document_srl', $document_srl);
111  }
112  Context::set('oDocument', $oDocument);
113 
114  if($this->module_info->mskin)
115  {
116  $templatePath = (sprintf($this->module_path.'m.skins/%s', $this->module_info->mskin));
117  }
118  else
119  {
120  $templatePath = ($this->module_path.'m.skins/default');
121  }
122 
123  $page_content = $oTemplate->compile($templatePath, 'mobile');
124 
125  return $page_content;
126  }
127 
129  {
130  // check if it is http or internal file
131  if($this->path)
132  {
133  if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file);
134  else $content = $this->executeFile($this->path, $this->interval, $this->cache_file);
135  }
136 
137  return $content;
138  }
139 }
140 /* End of file page.mobile.php */
141 /* Location: ./modules/page/page.mobile.php */
setTemplateFile($filename)
getController($module_name)
Definition: func.inc.php:90
removeFile($filename)
executeFile($target_file, $caching_interval, $cache_file)
Create a cache file in order to include if it is an internal file.
Definition: page.view.php:171
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
page view class of the module
Definition: page.view.php:8
_getOutsideContent()
$document_srl
Definition: ko.install.php:279
_getWidgetContent()
Definition: page.mobile.php:46
getHtmlPage($path, $caching_interval, $cache_file)
Save the file and return if a file is requested by http.
Definition: page.view.php:133
_getArticleContent()
Definition: page.mobile.php:93
$oDocumentModel
Definition: ko.install.php:259
const _XE_PATH_
Definition: config.inc.php:49
readFile($filename)
$obj module_srl
Definition: ko.install.php:270
getModel($module_name)
Definition: func.inc.php:145