forked from tempus707/xe-module-planet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanet.info.php
412 lines (346 loc) · 11.1 KB
/
planet.info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?php
class planetInfo extends Object {
var $planet_srl = null;
var $module_srl = null;
var $member_srl = null;
var $photo_src = null;
var $planet_title = null;
var $colorset = null;
function planetInfo($planet_srl = 0) {
if(!$planet_srl) return;
$this->setPlanet($planet_srl);
}
function setPlanet($planet_srl) {
$this->module_srl = $this->planet_srl = $planet_srl;
$this->_loadFromDB();
}
function _loadFromDB() {
if(!$this->planet_srl) return;
$args->module_srl = $this->planet_srl;
$output = executeQuery('planet.getPlanet', $args);
if(!$output->toBool()||!$output->data) return;
$this->setAttribute($output->data);
}
function setAttribute($attribute) {
if(!$attribute->module_srl) {
$this->planet_srl = null;
return;
}
$this->module_srl = $this->planet_srl = $attribute->module_srl;
$this->member_srl = $attribute->member_srl;
$this->colorset = $attribute->colorset;
$this->adds($attribute);
}
function isHome() {
$module_info = Context::get('module_info');
if($this->getModuleSrl() == $module_info->module_srl) return true;
return false;
}
function getColorset() {
if($this->isHome() || !$this->colorset) {
$module_info = Context::get('module_info');
return $module_info->colorset;
}
return $this->colorset;
}
function getBrowserTitle() {
if(!$this->isExists()) return;
return $this->get('browser_title');
}
function getPlanetTitle() {
if(!$this->isExists()) return;
return $this->get('planet_title');
}
function getPhotoSrc($width=96,$height=96) {
if(!$this->isExists()) return;
$oPlanetModel = &getModel('planet');
return $oPlanetModel->getPlanetPhotoSrc($this->planet_srl, $width, $height);
}
function getMid() {
if(!$this->isExists()) return;
return $this->get('mid');
}
function getMemberSrl() {
if(!$this->isExists()) return;
return $this->get('member_srl');
}
function getModuleSrl() {
if(!$this->isExists()) return;
return $this->getPlanetSrl();
}
function getPlanetSrl() {
if(!$this->isExists()) return;
return $this->planet_srl;
}
function getPlanetMid() {
if(!$this->isExists()) return;
return $this->get('mid');
}
function getNickName() {
if(!$this->isExists()) return;
return $this->get('nick_name');
}
function getUserName() {
if(!$this->isExists()) return;
// 사용자 이름이 없는 경우 닉네임 반환
if($this->get('member_srl') == $this->get('user_name')) return $this->get('nick_name');
return $this->get('user_name');
}
function getUserID() {
if(!$this->isExists()) return;
return $this->get('getUserID');
}
function isExists() {
return $this->planet_srl?true:false;
}
function isNoticeClosed() {
if(!$this->isExists()) return;
return $this->get('close_notice')=='Y'?true:false;
}
function getPrevDate($date) {
if(!$this->isExists()) return;
$args->cur_date = substr($date,0,8).'000000';
if(!$this->isHome()) $args->module_srl = $this->getModuleSrl();
$output = executeQuery('planet.getPrevDate', $args);
return substr($output->data->prev_date,0,8);
}
function getNextDate($date) {
if(!$this->isExists()) return;
if(!$date) return;
$args->cur_date = substr($date,0,8).'235959';
if(!$this->isHome()) $args->module_srl = $this->getModuleSrl();
$output = executeQuery('planet.getNextDate', $args);
return substr($output->data->next_date,0,8);
}
function isMyPlanet($planet = null) {
if(!$this->isExists()) return;
if(!Context::get('is_logged')) return false;
$logged_info = Context::get('logged_info');
if($planet) return $logged_info->member_srl == $planet->get('member_srl');
return $logged_info->member_srl == $this->get('member_srl');
}
function isMyFavorite($planet) {
if(!$this->isExists()) return false;
if($planet->isMyPlanet()) return true;
$args->module_srl = $this->getModuleSrl();
$args->reg_planet_srl = $planet->getModuleSrl();
$output = executeQuery('planet.getMyFavorite', $args);
if($output->data->count>0) return true;
return false;
}
function getPermanentUrl() {
if(!$this->isExists()) return;
return getUrl('','mid',$this->getMid());
}
function getTags() {
//static $tags = null;
if(!$this->isExists()) return;
//if(!is_null($tags)) return $tags;
$args->module_srl = $this->planet_srl;
$output = executeQueryArray('planet.getPlanetTag', $args);
if(!$output->toBool() || !$output->data) return array();
$tags = array();
foreach($output->data as $key => $val) $tags[] = $val->tag;
return $tags;
}
function getTagsString() {
if(!$this->isExists()) return;
return join(',',$this->getTags());
}
function isRssEnabled() {
static $open_rss = null;
if(!$this->isExists()) return;
if(is_null($open_rss)) {
$oRssModel = &getModel('rss');
$module_info = $oRssModel->getRssModuleConfig($this->getModuleSrl());
$open_rss = $module_info->open_rss;
}
return $open_rss=='Y'?true:false;
}
/**
* @brief 최신 업데이트 글 추출
* mid : 대상 플래닛, null이면 전체 글 대상
* date : 선택된 일자(필수값, 없으면 오늘을 대상으로 함)
* page : 페이지 번호
* list_count : 추출 대상 수
**/
function getNewestContentList($date = null, $page=1, $list_count = 10,$sort_index='documents.listorder',$order='asc') {
if(!$this->isExists()) return;
if(!$page) $page = 1;
if(!$date) $date = date("Ymd");
// 전체 글을 추출 (module='planet'에 대해서 추출해야 하기에 document 모델을 사용하지 않음)
if(!$this->isHome()) $args->mid = $this->getMid();
$args->date = $date;
$args->page = $page;
$args->sort_index = $sort_index;
$args->order = $order;
$args->list_count = $list_count;
$output = executeQueryArray('planet.getPlanetNewestContentList', $args);
if(!$output->toBool()) return $output;
if(count($output->data)) {
foreach($output->data as $key => $val) {
unset($oPlanet);
$oPlanet = new PlanetItem();
$oPlanet->setAttribute($val);
$output->data[$key] = $oPlanet;
}
}
return $output;
}
/**
* @brief 댓글이 달렸는데 확인하지 않은 글
**/
function getCatchContentList($page=1) {
if(!$page) $page = 1;
$args->module_srl = $this->getModuleSrl();
$args->page = $page;
$output = executeQueryArray('planet.getCatchContentList', $args);
if(!$output->toBool()) return $output;
if(count($output->data)) {
foreach($output->data as $key => $val) {
unset($oPlanet);
$oPlanet = new PlanetItem();
$oPlanet->setAttribute($val);
$output->data[$key] = $oPlanet;
}
}
return $output;
}
/**
* @brief 내가 댓글을 단 글에 댓글이 달렸는데 확인을 하지 않은 글
**/
function getFishingContentList($page=1) {
if(!$page) $page = 1;
$args->module_srl = $this->getModuleSrl();
$args->page = $page;
$output = executeQueryArray('planet.getFishingContentList', $args);
if(!$output->toBool()) return $output;
if(count($output->data)) {
foreach($output->data as $key => $val) {
unset($oPlanet);
$oPlanet = new PlanetItem();
$oPlanet->setAttribute($val);
$output->data[$key] = $oPlanet;
}
}
return $output;
}
/**
* @brief @nickname 으로 소환 받은 글
**/
function getCallingContentList($page=1) {
if(!$page) $page = 1;
$args->module_srl = $this->getModuleSrl();
$args->page = $page;
$output = executeQueryArray('planet.getCallingContentList', $args);
if(!$output->toBool()) return $output;
if(count($output->data)) {
foreach($output->data as $key => $val) {
unset($oPlanet);
$oPlanet = new PlanetItem();
$oPlanet->setAttribute($val);
$output->data[$key] = $oPlanet;
}
}
return $output;
}
/**
* @brief 관심 태그로 등록된 글 가져오기
**/
function getInterestTagContentList($date, $page=1) {
if(!$page) $page = 1;
$args->module_srl = $this->getModuleSrl();
$args->date = $date;
$args->page = $page;
$output = executeQueryArray('planet.getInterestTagContentList', $args);
if(!$output->toBool()) return $output;
if(count($output->data)) {
foreach($output->data as $key => $val) {
unset($oPlanet);
$oPlanet = new PlanetItem();
$oPlanet->setAttribute($val);
$output->data[$key] = $oPlanet;
}
}
return $output;
}
/**
* @brief 플래닛 마지막 글 쓴 날짜 return
**/
function getContentLastDay() {
if(!$this->isExists()) return;
if(!$this->isHome()) $args->module_srl = $this->getModuleSrl();
$args->date = $date . '235959';
$output = executeQuery('planet.getPlanetContentLastDay', $args);
if(!$output->toBool() || !$output->data) return date("Ymd");
$last_day = $output->data->last_date;
if(!$last_day) $last_day = date("Ymd");
$last_day = substr($last_day,0,8);
if(!$last_day || $last_day > date("Ymd") ) return date("Ymd");
return $last_day;
}
function getInterestTags() {
if(!$this->isExists()) return;
$oPlanetModel = &getModel('planet');
return $oPlanetModel->getInterestTags($this->module_srl);
}
/**
* @brief 전체 태그중 인기 태그 return
* mid : 대상 플래닛 (null이면 전체 플래닛)
* shuffle : 태그 결과값에 rank를 부여하고 shuffle
* list_coutn : 추출 대상 수
**/
function getPopularTags($shuffle = false, $list_count = 100) {
if(!$this->isExists()) return;
if(!$this->isHome()) $args->mid = $this->getMid();
$cache_file = sprintf('%sfiles/cache/planet/%s/%d.%d.txt', _XE_PATH_,getNumberingPath($this->getModuleSrl(),3), $shuffle?1:0,$list_count);
if(!file_exists($cache_file)||filemtime($cache_file)<time()-60*5) {
$args->list_count = $list_count;
// 24시간 이내의 태그중에서 인기 태그를 추출
$args->date = date("YmdHis", time()-60*60*24);
$output = executeQueryArray('planet.getPlanetPopularTags',$args);
if(!$output->toBool() || !$output->data) return array();
$tags = array();
$max = 0;
$min = 99999999;
foreach($output->data as $key => $val) {
$tag = $val->tag;
$count = $val->count;
if($max < $count) $max = $count;
if($min > $count) $min = $count;
$tags[] = $val;
}
if($shuffle) {
$mid2 = $min+(int)(($max-$min)/2);
$mid1 = $mid2+(int)(($max-$mid2)/2);
$mid3 = $min+(int)(($mid2-$min)/2);
$output = null;
foreach($tags as $key => $item) {
if($item->count > $mid1) $rank = 1;
elseif($item->count > $mid2) $rank = 2;
elseif($item->count > $mid3) $rank = 3;
else $rank= 4;
$tags[$key]->rank = $rank;
}
shuffle($tags);
}
FileHandler::writeFile($cache_file, serialize($tags));
} else {
$tags = unserialize(FileHandler::readFile($cache_file));
}
return $tags;
}
function getMe2dayUID() {
return $this->get('me2day_uid');
}
function getMe2dayUKey() {
return $this->get('me2day_ukey');
}
function getMe2dayAuthPush() {
return $this->get('me2day_autopush')=='Y'?true:false;
}
function getPhoneNumber(){
return $this->get('phone_number');
}
}
?>