Skip to content

Commit

Permalink
refs #1249
Browse files Browse the repository at this point in the history
  * 최근 댓글 출력 부분 완성
  • Loading branch information
inureyes committed Nov 28, 2009
1 parent 525b66e commit 417116a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion framework/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private function URIinterpreter() {
$interfacePath = 'interface/blog/'.$pathPart.'/index.php';
break;
case 'i':
if(in_array($uri['fragment'][1],array('entry'))) {
if(in_array($uri['fragment'][1],array('entry','comment'))) {
$pathPart = 'i/'.$uri['fragment'][1];
} else {
$pathPath = 'i/';
Expand Down
34 changes: 27 additions & 7 deletions interface/i/comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,36 @@
define('__TEXTCUBE_IPHONE__', true);
require ROOT . '/library/preprocessor.php';
requireView('iphoneView');
list($entries, $paging) = getEntryWithPaging($blogid, $suri['id']);
$entry = $entries ? $entries[0] : null;
if(isset($_GET['page'])) $page = $_GET['page'];
else $page = 1;
if(!empty($suri['id'])) { // entry-related comment print
list($entries, $paging) = getEntryWithPaging($blogid, $suri['id']);
$entry = $entries ? $entries[0] : null;
?>
<div id="comment_<?php echo $entry['id']."_".time();?>" title="Comment <?php echo $entry['id'];?>" selected="false">
<?php
printIphoneCommentView($entry['id']);
?>
<?php
printIphoneCommentView($entry['id']);
?>
<fieldset class="navi margin-top10">
<?php
printIphoneNavigation($entry, false, true);
<?php
printIphoneNavigation($entry, false, true);
?>
</fieldset>
</div>
<?php

} else { // All comments
?>
<div id="comment_<?php echo time();?>" title="<?php echo _text('최근 댓글');?>" selected="false">
<?php
printIphoneRecentCommentView($page);
?>
<fieldset class="navi margin-top10">
<?php
printIphoneNavigation($entry, false, false, $paging, 'comment');
?>
</fieldset>
</div>
<?php
}
?>
4 changes: 2 additions & 2 deletions interface/i/guestbook/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
if(isset($suri['id'])) $page = $suri['id'];
else $page = 1;
?>
<div id="guestbook_<?php echo time();?>" title="Guestbook" selected="false">
<div id="guestbook_<?php echo time();?>" title="<?php echo _text('방명록');?>" selected="false">
<?php
printIphoneGuestbookView($page);
?>
<fieldset class="navi margin-top10">
<?php
printIphoneNavigation(0, false, false, $paging);
printIphoneNavigation(0, false, false, $paging, 'guestbook');
?>
</fieldset>
</div>
6 changes: 4 additions & 2 deletions library/model/blog.comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ function getCommentCommentsNotified($parent) {
function getCommentsWithPaging($blogid, $entryId, $page, $count, $url = null, $prefix = '?page=', $postfix = '', $countItem = null) {
global $database;
$comments = array();
if($entryId != -1) {
$filter = 'AND entry = '.$entryId;
} else $filter = '';
$sql = "SELECT * FROM {$database['prefix']}Comments
WHERE blogid = $blogid
AND entry = $entryId
WHERE blogid = $blogid $filter
AND parent IS NULL
AND isfiltered = 0
ORDER BY written DESC";
Expand Down
29 changes: 16 additions & 13 deletions library/view/iphoneView.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,19 @@ function printIphoneHtmlFooter() {
<?php
}

function printIphoneNavigation($entry, $jumpToComment = true, $jumpToTrackback = true, $paging = null) {
function printIphoneNavigation($entry, $jumpToComment = true, $jumpToTrackback = true, $paging = null, $mode = 'entry') {
global $suri, $blogURL;
if($entry == 0) {
$mode = 'guestbook';
} else {
$mode = 'entry';
}
?>
<ul class="content navigation">
<?php
if (isset($paging['prev'])) {
?>
<li><a href="<?php echo $blogURL.'/'.$mode;?>/<?php echo $paging['prev'];?>" accesskey="1"><?php echo _text('이전 페이지');?></a></li>
<li><a href="<?php echo $blogURL.'/'.$mode;?>/<?php echo $paging['prefix'].$paging['prev'];?>" accesskey="1"><?php echo _text('이전 페이지');?></a></li>
<?php
}
if (isset($paging['next'])) {
?>
<li><a href="<?php echo $blogURL.'/'.$mode;?>/<?php echo $paging['next'];?>" accesskey="2"><?php echo _text('다음 페이지');?></a></li>
<li><a href="<?php echo $blogURL.'/'.$mode;?>/<?php echo $paging['prefix'].$paging['next'];?>" accesskey="2"><?php echo _text('다음 페이지');?></a></li>
<?php
}
if (!isset($paging)) {
Expand Down Expand Up @@ -432,11 +427,13 @@ function printIphoneTrackbackView($entryId) {
}
}

function printIphoneCommentView($entryId, $page = null) {
function printIphoneCommentView($entryId, $page = null, $mode = null) {
global $blogURL, $blogid, $skinSetting, $paging;
if(!is_null($page)) {
if ($mode == 'recent') { // Recent comments
list($comments, $paging) = getCommentsWithPaging($blogid, -1, $page, 10, null, '?page=');
} else if(!is_null($page)) { // Guestbook
list($comments, $paging) = getCommentsWithPagingForGuestbook($blogid, $page, $skinSetting['commentsOnGuestbook']);
} else {
} else { // Comments related to specific article
$comments = getComments($entryId);
}
if (count($comments) == 0) {
Expand All @@ -458,7 +455,7 @@ function printIphoneCommentView($entryId, $page = null) {
</span>
</li>
<li class="body">
<?php echo ($commentItem['secret'] && doesHaveOwnership() ? '<div class="hiddenComment" style="font-weight: bold; color: #e11">'._t('Secret Comment').' &gt;&gt;</div>' : '').nl2br(addLinkSense(htmlspecialchars($commentItem['comment'])));?>
<?php echo ($commentItem['secret'] && doesHaveOwnership() ? '<div class="hiddenComment" style="font-weight: bold; color: #e11">'.($entryId == 0 ? _text('비밀 방명록') : _text('비밀 댓글')).' &gt;&gt;</div>' : '').nl2br(addLinkSense(htmlspecialchars($commentItem['comment'])));?>
</li>
<?php
foreach (getCommentComments($commentItem['id']) as $commentSubItem) {
Expand All @@ -482,13 +479,19 @@ function printIphoneCommentView($entryId, $page = null) {
<?php
}
}
printIphoneCommentFormView($entryId, 'Write comment', 'comment');
if($mode != 'recent') {
printIphoneCommentFormView($entryId, 'Write comment', 'comment');
}
}

function printIphoneGuestbookView($page) {
return printIphoneCommentView(0, $page);
}

function printIphoneRecentCommentView($page) {
return printIphoneCommentView(1, $page, 'recent');
}

function printIphoneCommentFormView($entryId, $title, $actionURL) {
global $blogURL;
?>
Expand Down

0 comments on commit 417116a

Please # to comment.