|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class layout |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* high class of the layout module |
|
7
|
|
|
*/ |
|
8
|
|
|
class layout extends ModuleObject |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Implement if additional tasks are necessary when installing |
|
12
|
|
|
* @return Object |
|
13
|
|
|
*/ |
|
14
|
|
|
function moduleInstall() |
|
15
|
|
|
{ |
|
16
|
|
|
// Create a directory to be used in the layout |
|
17
|
|
|
FileHandler::makeDir('./files/cache/layout'); |
|
18
|
|
|
|
|
19
|
|
|
return new Object(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* a method to check if successfully installed |
|
24
|
|
|
* @return boolean |
|
25
|
|
|
*/ |
|
26
|
|
|
function checkUpdate() |
|
27
|
|
|
{ |
|
28
|
|
|
$oDB = &DB::getInstance(); |
|
29
|
|
|
$oModuleModel = getModel('module'); |
|
30
|
|
|
$oModuleController = getController('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
|
|
View Code Duplication |
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
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Execute update |
|
67
|
|
|
* @return Object |
|
68
|
|
|
*/ |
|
69
|
|
|
function moduleUpdate() |
|
70
|
|
|
{ |
|
71
|
|
|
$oDB = &DB::getInstance(); |
|
72
|
|
|
$oModuleModel = getModel('module'); |
|
|
|
|
|
|
73
|
|
|
$oModuleController = getController('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
|
|
View Code Duplication |
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 Object(0, 'success_updated'); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Re-generate the cache file |
|
125
|
|
|
* @return void |
|
126
|
|
|
*/ |
|
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 */ |
|
139
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.