From eff98560546ab9a564792c268854445fdf789893 Mon Sep 17 00:00:00 2001 From: Anthony Parsons Date: Sun, 13 Nov 2005 23:25:16 +0000 Subject: [PATCH] Experimental paged topiclists. Expect breakage. --- css/b-type.css | 6 +++-- css/core-layout.css | 2 +- css/furry-a.css | 6 ++--- css/furry-l.css | 8 +++---- css/scaly-a.css | 4 ++-- lib/class.anonuser.php | 5 ++-- lib/class.boardlist_default.php | 2 +- lib/class.boardlist_so1.php | 4 ++-- lib/class.iface_messagelist.php | 4 ++-- lib/class.iface_topiclist.php | 28 ++++++++++++++++++++++ lib/class.messagelist_flat.php | 6 ++--- lib/class.messagelist_irc.php | 2 +- lib/class.topiclist_default.php | 53 +++++++++++++++++++++++++++++++---------- lib/class.topiclist_tl.php | 13 ++++++++-- messagelist.php | 17 +++++++++---- post.php | 10 ++++---- topiclist.php | 31 ++++++++++++++++++++---- 17 files changed, 149 insertions(+), 52 deletions(-) create mode 100644 lib/class.iface_topiclist.php diff --git a/css/b-type.css b/css/b-type.css index cd870fa..01adc54 100644 --- a/css/b-type.css +++ b/css/b-type.css @@ -10,8 +10,8 @@ th[scope="col"] { -moz-border-radius: 1em 1em 0 0; border: 1px #f3fcff; border-s th[scope="row"] { -moz-border-radius: 1em 0 0 1em; text-align: right; } th[scope="row"]::after { content: " >"; } -.nl li::after { content: " | "; } -.nl li:last-child::after { content: ""; } +.nl > *::after { content: " | "; } +.nl > *:last-child::after { content: ""; } table { width: 99%; margin: 0.5% auto; border-spacing: 0 1px; } td { padding: 2px; } @@ -33,6 +33,8 @@ legend { background: #67d; border: 1px solid #fff; color: #fff; font-size: 110%; dt { font-weight: bold; } dt::after { content: ":"; } dd { border: solid #dfdfdf; border-width: 0 0 2px 2em; margin: 0 0 2px; padding: 2px; } +#pagelist-head dt::after, #pagelist-foot dt::after, #userheader li:first-child::after { content: ""; } +#pagelist-head dd, #pagelist-foot dd { border: none; } a { color: #00004a; } a:visited { color: #00004f; } diff --git a/css/core-layout.css b/css/core-layout.css index 2ce1594..2e82df1 100644 --- a/css/core-layout.css +++ b/css/core-layout.css @@ -3,7 +3,7 @@ h1, h2, h3, h4, h5, h6, html, body, p { margin: 0; padding: 0; } /* navigation lists */ .nl, .nl > ul { margin: 0; padding: 0; } -.nl li, .nl > ul { display: inline; } +.nl > * { display: inline; } /* stuff */ #boardlist-foot { margin: 0; padding: 0; list-style: none; } diff --git a/css/furry-a.css b/css/furry-a.css index fd4c6b7..81f0df5 100644 --- a/css/furry-a.css +++ b/css/furry-a.css @@ -31,9 +31,9 @@ input[type=submit]:hover, button:hover { border: 1px #f00 solid; cursor: pointer; } .nl, #footer { background: #666 url(furry.png) repeat-x; color: #fff; } -.nl li { border: 1px outset #eee; background: #fff url(wb_back.png) 0 1px repeat-x; } -.nl li:hover { border-style: inset; background-position: 0 -20px; } -.nl li a { padding: 0 0.5em; text-decoration: none; } +.nl > * { border: 1px outset #eee; background: #fff url(wb_back.png) 0 1px repeat-x; } +.nl > *:hover { border-style: inset; background-position: 0 -20px; } +.nl > * a { padding: 0 0.5em; text-decoration: none; } #footer { color: #fff; } #footer fieldset { border: none; } #footer p { background: #666; } diff --git a/css/furry-l.css b/css/furry-l.css index 61c41ea..d48eb3b 100644 --- a/css/furry-l.css +++ b/css/furry-l.css @@ -16,10 +16,10 @@ input[type=text], input[type=password], textarea { padding: 0.1em 0.5em; vertica input[type=submit], button { padding: 0.2em; } .nl { text-align: center; list-style: none; margin: 0.5em 0; padding: 0; } -.nl li { display: inline; padding: 0.1em; margin: 0 0.5em; } -.nl li a { padding: 0 0.5em; } -.nl li div, -.nl li form { display: inline; padding: 0 0.1em; } +.nl > * { display: inline; padding: 0.1em; margin: 0 0.5em; } +.nl > * a { padding: 0 0.5em; } +.nl > * div, +.nl > * form { display: inline; padding: 0 0.1em; } #footer { text-align: right; } #footer fieldset { display: inline; padding: 0.1em; vertical-align: bottom; } diff --git a/css/scaly-a.css b/css/scaly-a.css index accc0e4..d2bf00f 100644 --- a/css/scaly-a.css +++ b/css/scaly-a.css @@ -7,8 +7,8 @@ input[type=submit]:hover, button:hover { border: 2px #080 outset; cursor: point input[type=submit]:active, button:active { border: 2px #080 inset; } .nl, #footer{ background-image: url(scaly); } -.nl li { background-color: #212; border-color: #212; } -.nl li a { color: #ccf; } +.nl > * { background-color: #212; border-color: #212; } +.nl > * a { color: #ccf; } #footer p { background: transparent; } #footer legend { display: none; } diff --git a/lib/class.anonuser.php b/lib/class.anonuser.php index ad86565..31e6a43 100644 --- a/lib/class.anonuser.php +++ b/lib/class.anonuser.php @@ -15,7 +15,8 @@ class anonuser function __construct() { $this->userlinks = array( - 'Log In' => '#login_u' + 'Log In' => '#login_u', + 'Register' => 'register' ); $this->attrcache = array( @@ -78,4 +79,4 @@ class anonuser return ( $timestamp == 0 ? 'N/A' : date('Y-m-d H:i:s', $timestamp) ); } } -?> \ No newline at end of file +?> diff --git a/lib/class.boardlist_default.php b/lib/class.boardlist_default.php index 589a102..14cfd13 100644 --- a/lib/class.boardlist_default.php +++ b/lib/class.boardlist_default.php @@ -47,7 +47,7 @@ class boardlist_default echo '',"\n", ' ',( $board['v'] ? - ''.$board['name'].'' : $board['name'] ),"
\n", + ''.$board['name'].'' : $board['name'] ),"
\n", ' ',$board['caption'],"\n", ' ',$posts,"\n", ' ',$topics,"\n", diff --git a/lib/class.boardlist_so1.php b/lib/class.boardlist_so1.php index fc6ba02..59ae885 100644 --- a/lib/class.boardlist_so1.php +++ b/lib/class.boardlist_so1.php @@ -53,7 +53,7 @@ class boardlist_so1 echo '',"\n", ' ',( $board['v'] ? - ''.$board['name'].'' : $board['name'] ),"
\n", + ''.$board['name'].'' : $board['name'] ),"
\n", ' ',$board['caption'],"\n", ' ',$postcount,"\n", ' ',$topiccount,"\n"; @@ -63,7 +63,7 @@ class boardlist_so1 " From: %s\n". " at %s
\n". ' in topic: %s'."\n". + ' href="messagelist?%d">%s'."\n". "\n", $user->namelink($postinfo['userid'], $postinfo['alias']), diff --git a/lib/class.iface_messagelist.php b/lib/class.iface_messagelist.php index 97cba96..f60a6a8 100644 --- a/lib/class.iface_messagelist.php +++ b/lib/class.iface_messagelist.php @@ -7,7 +7,7 @@ interface iface_messagelist * Constructor * @param int $topicID The ID number of topic to display * @param int $mpp Number of messages per page - * @param int $page Page number (0-indexed) + * @param int $page Page number (starts from 0) */ function __construct($topicid, $mpp, $page); @@ -18,7 +18,7 @@ interface iface_messagelist public function display(); /** - * Return (not echo) list of pages in a XHTML li format (with no ul tags) + * Return (not echo) list of pages in a XHTML dd format (with no dl tags) * * If the class can't handle pages for whatever reason, then return null instead. * @return string|null diff --git a/lib/class.iface_topiclist.php b/lib/class.iface_topiclist.php new file mode 100644 index 0000000..e005803 --- /dev/null +++ b/lib/class.iface_topiclist.php @@ -0,0 +1,28 @@ + diff --git a/lib/class.messagelist_flat.php b/lib/class.messagelist_flat.php index 3289701..347be4b 100644 --- a/lib/class.messagelist_flat.php +++ b/lib/class.messagelist_flat.php @@ -57,10 +57,10 @@ class messagelist_flat implements iface_messagelist $tmp = ''; for ( $i = 0; $i < $this->msgsum; $i += $this->mpp ) if ( $i/$this->mpp == $this->page ) - $tmp .= '
  • ['.($i/$this->mpp+1)."]
  • \n"; + $tmp .= '
    ['.($i/$this->mpp+1)."]
    \n"; else - $tmp .= '
  • '. - ($i/$this->mpp+1)."
  • \n"; + $tmp .= '
    '.($i/$this->mpp+1)."
    \n"; return $tmp; } } diff --git a/lib/class.messagelist_irc.php b/lib/class.messagelist_irc.php index 2471b58..f4bdf46 100644 --- a/lib/class.messagelist_irc.php +++ b/lib/class.messagelist_irc.php @@ -24,7 +24,7 @@ class messagelist_irc extends messagelist_flat implements iface_messagelist LIMIT '.($this->page*$this->mpp).', '.$this->mpp); $points = ( $user instanceof authuser ? - ' [+] (%2$d) [-]'."\n" : '(%2$d)' ); + ' [+] (%2$d) [-]'."\n" : '(%2$d)' ); while ( $msg = $msgs->fetch_assoc() ) { // Opening tags, MsgID link, userinfo diff --git a/lib/class.topiclist_default.php b/lib/class.topiclist_default.php index b43312b..37cef5d 100644 --- a/lib/class.topiclist_default.php +++ b/lib/class.topiclist_default.php @@ -3,13 +3,33 @@ $classes['topiclist']['default'] = array('name' => 'SO2', 'ID' => 0); -class topiclist_default +class topiclist_default implements iface_topiclist { + protected $tpp; + protected $page; + protected $topicsum; + function __construct($boardid, $tpp = 35, $page = 0) { global $DB, $user; + $this->tpp = $tpp; + $this->page = $page; + list($this->topicsum) = $DB->query('SELECT COUNT(*) FROM `topics` WHERE `boardid` = @boardid')->fetch_row(); + $a = 1; + $topics = $DB->query( + 'SELECT `topics`.`topicid`, `topic_title`, `topics`.`userid`, `alias`, `messageid`, `mtime`, + (SELECT COUNT(*) FROM `messages` WHERE `messages`.`topicid` = `topics`.`topicid`) AS `posts` + FROM `topics` + LEFT JOIN `messages` ON `lastpost` = `messageid` + LEFT JOIN `users` ON `topics`.`userid` = `users`.`userid` + WHERE `boardid` = @boardid + AND `topics`.`visibility` IN(\'normal\', \'sticky\') + GROUP BY `topicid` + ORDER BY `mtime` DESC + LIMIT '.($this->page*$this->tpp).', '.$this->tpp); + echo '',"\n", " \n", @@ -21,21 +41,11 @@ class topiclist_default "\n", "\n"; - $topics = $DB->query( - 'SELECT `topics`.`topicid`, `topic_title`, `topics`.`userid`, `alias`, `messageid`, `mtime`, - (SELECT COUNT(*) FROM `messages` WHERE `messages`.`topicid` = `topics`.`topicid`) AS `posts` - FROM `topics` - LEFT JOIN `messages` ON `lastpost` = `messageid` - LEFT JOIN `users` ON `topics`.`userid` = `users`.`userid` - WHERE `boardid` = '.$boardid.' - AND `topics`.`visibility` IN(\'normal\', \'sticky\') - GROUP BY `topicid` - ORDER BY `mtime` DESC'); while ( $topic = $topics->fetch_assoc() ) { echo '\n", - ' \n", + ' \n", ' \n", ' \n", ' \n", @@ -43,5 +53,24 @@ class topiclist_default } echo "\n
    ',$topic['topic_title'],"',$topic['topic_title'],"',$user->namelink($topic['userid']),"',$topic['posts'],"',$user->fdate($topic['mtime']),"
    \n"; } + + function display() + { + } + + public function pagelist() + { + if ( $this->topicsum < $this->tpp ) + return null; + + $tmp = ''; + for ( $i = 0; $i < $this->topicsum; $i += $this->tpp ) + if ( $i/$this->tpp == $this->page ) + $tmp .= '
    ['.($i/$this->tpp+1)."]
    \n"; + else + $tmp .= '
    '.($i/$this->tpp+1)."
    \n"; + return $tmp; + } } ?> diff --git a/lib/class.topiclist_tl.php b/lib/class.topiclist_tl.php index 6163fd0..9418820 100644 --- a/lib/class.topiclist_tl.php +++ b/lib/class.topiclist_tl.php @@ -3,7 +3,7 @@ $classes['topiclist']['TL'] = array('name' => 'Twisted Legacy', 'ID' => 1); -class topiclist_tl +class topiclist_tl implements iface_topiclist { function __construct($boardid, $tpp = 35, $page = 0) { @@ -39,7 +39,7 @@ class topiclist_tl while ( $topic = $topics->fetch_assoc() ) { echo '\n", - ' ',$topic['topic_title'],"\n", + ' ',$topic['topic_title'],"\n", ' ',$user->namelink($topic['userid'], $topic['alias']),"\n", ' ',$topic['posts'],"\n", ' ',$user->fdate($topic['mtime']),'
    By: ', @@ -48,5 +48,14 @@ class topiclist_tl } echo "\n"; } + + function display() + { + } + + function pagelist() + { + return null; + } } ?> diff --git a/messagelist.php b/messagelist.php index 69a0f61..ba4f442 100644 --- a/messagelist.php +++ b/messagelist.php @@ -6,14 +6,19 @@ require 'con.php'; $page->title = 'Message List'; -if ( isset($_GET['topic']) ) { +if ( is_numeric($_SERVER['QUERY_STRING']) ) + $topicid = intval($_SERVER['QUERY_STRING']); +elseif ( isset($_GET['topic']) ) $topicid = intval($_GET['topic']); + +if ( isset($topicid) ) { $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`, `view_level`, `post_level`, `topic_level`, `topic_title` FROM `boards` NATURAL LEFT JOIN `topics` WHERE `topicid` = '.$topicid)->fetch_row(); -} +} else + $page->errorfooter('topicid'); // Check for valid topic ID if ( !is_array($topic) ) @@ -25,7 +30,7 @@ if ( $topic[2] > $user->level ) $page->title .= ': '.$topic[5]; -$page->nav['Topic List: '.$topic[0]] = 'topiclist?board='.$topic[1]; +$page->nav['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1]; if ( $user instanceof authuser && $user->level >= $topic[3] ) $user->userlinks['Post Message'] = 'post?topic='.$topicid; @@ -46,19 +51,21 @@ switch ( $user->msglist_layout ) { $mlist = new messagelist_threaded($topicid, $posts, $start); break; case 2: $mlist = new messagelist_irc($topicid, $posts, $start); break; + default: + throw new OutOfBoundsException('user->msglist_layout is out of valid range'); } $l = $mlist->pagelist(); if ( $user instanceof authuser && $l ) - echo '
    Pages:
      ',"\n$l
    \n"; + echo '
    Pages:
    '.$l."
    \n"; echo '
    \n"; $mlist->display(); echo "
    \n"; if ( $user instanceof authuser && $l ) - echo '
    Pages:
      ',"\n$l
    \n"; + echo '
    Pages:
    '.$l."
    \n"; $page->pagefooter(); ?> diff --git a/post.php b/post.php index b6b015b..8f2b03e 100644 --- a/post.php +++ b/post.php @@ -47,9 +47,9 @@ if ( $board[2] > $user->level ) $page->errorfooter('level', $board[2]); // If this is a real board and they're allowed in add the links -$page->nav['Topic List: '.$board[0]] = 'topiclist?board='.$boardid; +$page->nav['Topic List: '.$board[0]] = 'topiclist?'.$boardid; if ( isset($topicid) ) - $page->nav['Message List: '.$topic[0]] = 'messagelist?topic='.$topicid; + $page->nav['Message List: '.$topic[0]] = 'messagelist?'.$topicid; $user->userheader(); @@ -131,9 +131,9 @@ if ( isset($_POST['post']) || isset($_POST['preview']) ) { )'); $DB->commit(); - $r = 'topiclist?board='.$boardid; + $r = 'topiclist?'.$boardid; if ( isset($topicid) ) - $r = 'messagelist?topic='.$topicid; + $r = 'messagelist?'.$topicid; $page->footer('

    Message Posted. Return to from which you came.

    '); @@ -167,7 +167,7 @@ elseif ( isset($topic) ) else echo '
    ',"\n", '
    Topic',"\n", - ' \n", "
    \n"; diff --git a/topiclist.php b/topiclist.php index 7fbfb40..48a39e1 100644 --- a/topiclist.php +++ b/topiclist.php @@ -1,19 +1,20 @@ title = 'Topic List'; -$boardid = intval($_GET['board']); +$boardid = intval($_SERVER['QUERY_STRING']); $board = $DB->query('SELECT `board_name`, `view_level`, `topic_level` FROM `boards` WHERE `boardid` = '.$boardid)->fetch_row(); - if ( !is_array($board) ) $page->errorfooter('boardid'); +$DB->query('SET @boardid = '.$boardid); + $page->title .= ': '.$board[0]; if ( $board[1] > $user->level ) @@ -24,14 +25,34 @@ if ( $user instanceof authuser && $user->level >= $board[2] ) $user->userheader(); +if ( $user instanceof authuser ) { + $start = isset($_GET['page']) ? intval($_GET['page']) : 0; + $topics = isset($_GET['length']) && ($_GET['length'] <= 100) ? intval($_GET['length']) : $user->topics_page; +} else { + $start = 0; + $topics = $user->topics_page; +} + switch ( $user->topiclist_layout ) { case 0: - new topiclist_default($boardid); break; + $tlist = new topiclist_default($boardid, $topics, $start); break; case 1: - new topiclist_tl($boardid); break; + $tlist = new topiclist_tl($boardid, $topics, $start); break; default: throw new OutOfBoundsException('user->topiclist_layout is out of valid range'); } +$l = $tlist->pagelist(); + +if ( $user instanceof authuser && $l ) + echo '
    Pages:
    '.$l."
    \n"; + +echo '
    \n"; + $tlist->display(); +echo "
    \n"; + +if ( $user instanceof authuser && $l ) + echo '
    Pages:
    '.$l."
    \n"; + $page->pagefooter(); ?> -- 2.11.4.GIT