XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
layout.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class layout extends ModuleObject
9 {
14  function moduleInstall()
15  {
16  // Create a directory to be used in the layout
17  FileHandler::makeDir('./files/cache/layout');
18 
19  return new BaseObject();
20  }
21 
26  function checkUpdate()
27  {
28  $oDB = &DB::getInstance();
29  $oModuleModel = getModel('module');
31  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
32  if($oModuleModel->needUpdate($version_update_id))
33  {
34  // 2009. 02. 11 Add site_srl to layout table
35  if(!$oDB->isColumnExists('layouts', 'site_srl')) return true;
36  // 2009. 02. 26 Move the previous layout for faceoff
37  $files = FileHandler::readDir('./files/cache/layout');
38  for($i=0,$c=count($files);$i<$c;$i++)
39  {
40  $filename = $files[$i];
41  if(preg_match('/([0-9]+)\.html/i',$filename)) return true;
42  }
43 
44  if(!$oDB->isColumnExists('layouts', 'layout_type')) return true;
45 
46  $args = new stdClass();
47  $args->layout = '.';
48  $output = executeQueryArray('layout.getLayoutDotList', $args);
49  if($output->data && count($output->data) > 0)
50  {
51  foreach($output->data as $layout)
52  {
53  $layout_path = explode('.', $layout->layout);
54  if(count($layout_path) != 2) continue;
55  if(is_dir(sprintf(_XE_PATH_ . 'themes/%s/layouts/%s', $layout_path[0], $layout_path[1]))) return true;
56  }
57  }
58 
59  $oModuleController->insertUpdatedLog($version_update_id);
60  }
61 
62  return false;
63  }
64 
69  function moduleUpdate()
70  {
71  $oDB = &DB::getInstance();
72  $oModuleModel = getModel('module');
74  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
75  {
76  // 2009. 02. 11 Add site_srl to menu table
77  if(!$oDB->isColumnExists('layouts', 'site_srl'))
78  {
79  $oDB->addColumn('layouts','site_srl','number',11,0,true);
80  }
81  // 2009. 02. 26 Move the previous layout for faceoff
82  $oLayoutModel = getModel('layout');
83  $files = FileHandler::readDir('./files/cache/layout');
84  for($i=0,$c=count($files);$i<$c;$i++)
85  {
86  $filename = $files[$i];
87  if(!preg_match('/([0-9]+)\.html/i',$filename,$match)) continue;
88  $layout_srl = $match[1];
89  if(!$layout_srl) continue;
90  $path = $oLayoutModel->getUserLayoutPath($layout_srl);
91  if(!is_dir($path)) FileHandler::makeDir($path);
92  FileHandler::copyFile('./files/cache/layout/'.$filename, $path.'layout.html');
93  @unlink('./files/cache/layout/'.$filename);
94  }
95 
96  if(!$oDB->isColumnExists('layouts', 'layout_type'))
97  {
98  $oDB->addColumn('layouts','layout_type','char',1,'P',true);
99  }
100 
101  $args->layout = '.';
102  $output = executeQueryArray('layout.getLayoutDotList', $args);
103  if($output->data && count($output->data) > 0)
104  {
105  foreach($output->data as $layout)
106  {
107  $layout_path = explode('.', $layout->layout);
108  if(count($layout_path) != 2) continue;
109  if(is_dir(sprintf(_XE_PATH_ . 'themes/%s/layouts/%s', $layout_path[0], $layout_path[1])))
110  {
111  $args->layout = implode('|@|', $layout_path);
112  $args->layout_srl = $layout->layout_srl;
113  $output = executeQuery('layout.updateLayout', $args);
114  }
115  }
116  }
117 
118  $oModuleController->insertUpdatedLog($version_update_id);
119  }
120  return new BaseObject(0, 'success_updated');
121  }
122 
127  function recompileCache()
128  {
129  $path = './files/cache/layout';
130  if(!is_dir($path))
131  {
132  FileHandler::makeDir($path);
133  return;
134  }
135  }
136 }
137 /* End of file layout.class.php */
138 /* Location: ./modules/layout/layout.class.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
const __XE_VERSION__
Definition: config.inc.php:32
$output
Definition: ko.install.php:193
$layout_srl
Definition: ko.install.php:186
moduleUpdate()
$args
Definition: ko.install.php:185
$layout_path
a path of directory where layout files reside
getInstance($db_type=NULL)
Definition: DB.class.php:142
makeDir($path_string)
copyFile($source, $target, $force= 'Y')
const _XE_PATH_
Definition: config.inc.php:49
getModel($module_name)
Definition: func.inc.php:145
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:219
readDir($path, $filter= '', $to_lower=FALSE, $concat_prefix=FALSE)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
$oModuleController
Definition: ko.install.php:287
moduleInstall()
recompileCache()
checkUpdate()