forked from tempus707/xe-module-planet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanet.wap.php
108 lines (89 loc) · 3.87 KB
/
planet.wap.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
<?php
/**
* @class planetWAP
* @author misol ([email protected])
* @brief planet 모듈의 WAP class
* WML, mHTML 등 모바일 페이지 생성을 담당(스마트폰 제외^^)
**/
class planetWAP extends planet {
function procWAP(&$oMobile) {
$content = '';
// 플래닛의 기본 단위인 날짜를 미리 계산 모듈에 있는 동작인데... 애드온이 모듈보다 일찍 실행된다;
$last_date = $this->planet->getContentLastDay();
$date = Context::get('date');
if(!$date || $date > $last_date) $date = $last_date;
Context::set('date', $date);
Context::set('prev_date', $this->planet->getPrevDate($date));
Context::set('next_date', $this->planet->getNextDate($date));
$type = Context::get('type');
if(!$type) $type = 'all';
Context::set('type',$type);
$tagtab = null;
switch($type) {
case 'wantyou':
$sort_index = 'documents.voted_count';
$order = 'desc';
break;
case 'best':
$sort_index = 'documents.comment_count';
$order = 'desc';
break;
case 'all':
$sort_index = 'documents.list_order';
$order = 'asc';
break;
}
$page = Context::get('page');
$oPlanetModel = &getModel('planet');
$output = $oPlanetModel->getNewestContentList(null, $date, $page, 9, $sort_index, $order,$tagtab );
$title = Context::getBrowserTitle().' ['.zdate($date,'Y').Context::getLang('unit_year').
zdate($date,'m').Context::getLang('unit_month').
zdate($date,'d').Context::getLang('unit_day').']';
// 댓글 보기 일 경우
if($this->act == 'dispPlanetContentCommentList') {
$page = Context::get('page');
$document_srl = Context::get('document_srl');
$oPlanetModel = &getModel('planet');
$output = $oPlanetModel->getReplyList($document_srl,$page);
$reply_list = $output->data;
$title .= ' - '.Context::getLang('comment');
if(is_array($reply_list)) {
foreach($reply_list as $key => $reply) {
$content .= '[<strong>'.$reply->nick_name.'</strong>] ';
$content .= $reply->content;
}
}
// 상위 페이지를 목록으로 돌아가기로 지정
$oMobile->setUpperUrl( getUrl('act',''), Context::getLang('cmd_go_upper') );
} else {
if($output->page_navigation->total_page>1) {
if($output->page_navigation->cur_page < $output->page_navigation->last_page) {
// next/prevUrl 지정
$oMobile->setPrevUrl(getUrl('page',$output->page_navigation->cur_page+1), sprintf('%s (%d/%d)', Context::getLang('cmd_prev'), $output->page_navigation->cur_page+1, $output->page_navigation->total_page));
}
if($output->page_navigation->cur_page > 1) $oMobile->setNextUrl(getUrl('page',$output->page_navigation->cur_page-1), sprintf('%s (%d/%d)', Context::getLang('cmd_next'), $output->page_navigation->cur_page-1, $output->page_navigation->total_page));
}
if(!$output->data || !count($output->data)) $content .= Context::getLang('no_documents');
foreach($output->data as $no => $item) {
$obj = null;
$obj['href'] = getUrl('mid',$_GET['mid'],'document_srl',$item->get('document_srl'), 'act', 'dispPlanetContentCommentList');
$obj['link'] = '['.htmlspecialchars($item->getNickName()).'] '."\n";
$obj['link'] .= htmlspecialchars(strip_tags($item->getContent()));
if($item->getPostScript()) $obj['extra'] = Context::getLang('planet_postscript').htmlspecialchars($item->getPostScript());
if(is_array($item->getArrTags())) {
$obj['extra'] .= '<br />TAG:';
$obj['extra'] .= implode(', ',$item->getArrTags());
}
$obj['link'] = $obj['text'] = $obj['link'];
$childs[] = $obj;
}
$oMobile->setChilds($childs);
$prev_date = Context::get('prev_date');
if($prev_date) $oMobile->setEtcBtn(getUrl('date',$prev_date, 'document_srl',''), '<');
$next_date = Context::get('next_date');
if($next_date) $oMobile->setEtcBtn(getUrl('date',$next_date, 'document_srl',''), '>');
}
$oMobile->setTitle($title);
$oMobile->setContent($content);
}
}