[Slashdotjp-dev 1151] [678] * Add next and previous journal data to journal

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 6月 27日 (金) 16:05:08 JST


Revision: 678
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=slashdotjp&view=rev&rev=678
Author:   tach
Date:     2008-06-27 16:05:07 +0900 (Fri, 27 Jun 2008)

Log Message:
-----------
 * Add next and previous journal data to journal
   - use $journal_reader->getJournalByTime()
 * Disable to show comments when mobile mode

Modified Paths:
--------------
    slashjp/branches/2.5.0.192/debian/changelog
    slashjp/branches/2.5.0.192/plugins/Journal/Journal.pm
    slashjp/branches/2.5.0.192/plugins/Journal/journal.pl


-------------- next part --------------
Modified: slashjp/branches/2.5.0.192/debian/changelog
===================================================================
--- slashjp/branches/2.5.0.192/debian/changelog	2008-06-26 10:19:47 UTC (rev 677)
+++ slashjp/branches/2.5.0.192/debian/changelog	2008-06-27 07:05:07 UTC (rev 678)
@@ -16,8 +16,11 @@
     - for enabling pagination for top journals
   * Add new url for userdir_handler
     - Add "/journals" URL
+  * Add next and previous journal data to journal
+    - use $journal_reader->getJournalByTime()
+  * Disable to show comments when mobile mode
 
- -- Taku YASUI <tach****@osdn*****>  Thu, 26 Jun 2008 09:45:09 +0000
+ -- Taku YASUI <tach****@osdn*****>  Fri, 27 Jun 2008 07:03:00 +0000
 
 slash (2.5.0.192-13) unstable; urgency=low
 

Modified: slashjp/branches/2.5.0.192/plugins/Journal/Journal.pm
===================================================================
--- slashjp/branches/2.5.0.192/plugins/Journal/Journal.pm	2008-06-26 10:19:47 UTC (rev 677)
+++ slashjp/branches/2.5.0.192/plugins/Journal/Journal.pm	2008-06-27 07:05:07 UTC (rev 678)
@@ -697,7 +697,39 @@
 	}
 }
 
+sub getJournalByTime {
+	my($self, $sign, $journal, $options) = @_;
+	my $constants = getCurrentStatic();
+	$options = {} if !$options || ref($options) ne 'HASH';
+	my $limit = $options->{limit} || 1;
+	my $uid = int($options->{uid}) || undef;
+	my $where = "";
+	my $name  = 'journal_by_time';
+	my $order = $sign eq '<' ? 'DESC' : 'ASC';
 
+	# $journal->[0]: datetime string
+	# $journal->{1]: journaltext
+	# $journal->{2]: journaltitle
+	# $journal->[3]: journal_id
+	# $journal->[4]: format_id
+	# $journal->[5]: topic_id
+	# $journal->[6]: discussion_id
+
+	if ($uid) {
+		$where .= " AND uid=$uid";
+	}
+
+	my $returnable = $self->sqlSelectArrayRef(
+		'date, article, description, id, posttype, tid, discussion',
+		'journals JOIN journals_text USING (id)',
+		"date $sign '$journal->[0]'
+		 AND date <= NOW()
+		 $where",
+		 "ORDER by date $order LIMIT $limit"
+	);
+	return $returnable;
+}
+
 sub DESTROY {
 	my($self) = @_;
 	$self->{_dbh}->disconnect if !$ENV{GATEWAY_INTERFACE} && $self->{_dbh};

Modified: slashjp/branches/2.5.0.192/plugins/Journal/journal.pl
===================================================================
--- slashjp/branches/2.5.0.192/plugins/Journal/journal.pl	2008-06-26 10:19:47 UTC (rev 677)
+++ slashjp/branches/2.5.0.192/plugins/Journal/journal.pl	2008-06-27 07:05:07 UTC (rev 678)
@@ -428,6 +428,7 @@
 	my $collection = {};
 	my $user_change = {};
 	my $head_data = {};
+	my ($prev, $next);
 
 	my $slashdb = getCurrentDB();
 
@@ -518,6 +519,8 @@
 			$commentcount = $article->[6]
 				? $discussion->{commentcount}
 				: 0;
+			$next = $journal_reader->getJournalByTime('>', $article, { uid => $uid });
+			$prev = $journal_reader->getJournalByTime('<', $article, { uid => $uid });
 		} else {
 			$commentcount = $article->[6]
 				? $journal_reader->getDiscussion($article->[6], 'commentcount')
@@ -537,6 +540,8 @@
 			discussion	=> $article->[6],
 			id		=> $article->[3],
 			commentcount	=> $commentcount,
+			prev		=> $prev,
+			next		=> $next,
 		};
 	}
 
@@ -558,7 +563,7 @@
 
 	print getData('journalfoot');
 
-	if ($show_discussion) {
+	if (!$user->{mobile} && $show_discussion) {
 		printComments($discussion);
 	}
 


Slashdotjp-dev メーリングリストの案内
Back to archive index