SetLinksFormat( 'Back', ' | ', 'Next' ); $pagination->SetItemsPerPage(35); $pagination->SetLinksToDisplay(5); if (isset($_GET['page']) && is_numeric($_GET['page'])) { $pagination->SetCurrentPage($_GET['page']); } else { $pagination->SetCurrentPage(1); } $breadcrumb['Page ' . $pagination->currentPage] = "/viewJoke.wik?page=" . $pagination->currentPage; // B*+* 0000201 20070716 3:14P $sort = ' ORDER BY id '; $order = ' DESC '; if (isset($_GET['sort'])) { if(stripslashes(trim($_GET['sort'])) == 'title') $order = ' ASC '; $sort = ' ORDER BY REPLACE(' . stripslashes($_GET['sort']) . ', \'"\', \'\') ' . $order; } else $sort = $sort . $order; // B*+* 0000202 20070717 3:04P $pagination->setItemCount($database->oneField($database->prepareSql("SELECT COUNT(*) FROM articles WHERE approved='1' AND type='j'"))); $sqlId = $database->prepareSql("SELECT DISTINCT articles.title, articles.id, articles.timestamp, articles.text, itemratings.views, itemratings.comments FROM articles JOIN itemratings ON articles.id=itemratings.itemId WHERE approved='1' AND itemratings.itemType='joke' AND articles.type = 'j' " . $sort . " " . $pagination->GetSqlLimit()); // E*+* 0000202 20070717 3:04P // E*+* 0000201 20070716 3:14P $articles = $database->multipleRows($sqlId); if (!$articles) { $errorDisplay = new displayManager('error2'); $errorDisplay->addPlaceHolder('ERROR', "There is no news on this page.."); $itemTypeDisplay->addPlaceHolder('CONTENT', $errorDisplay->outputHtml(true)); } else { $gridDisplay = new displayManager('jokeGridHeader'); $gridRowDisplay = new displayManager('jokeGridRow'); $gridHtml = null; foreach($articles as $temp => $article) { $gridRowDisplay->addPlaceHolder('TITLE', trim(stripslashes($article['title']))); $gridRowDisplay->addPlaceHolder('ITEMID', $article['id']); $gridRowDisplay->addPlaceHolder('ITEMTYPE', 'joke'); $gridRowDisplay->addPlaceHolder('DATE', date('F j, y', $article['timestamp'])); $gridRowDisplay->addPlaceHolder('VIEWS', number_format($article['views'])); $gridRowDisplay->addPlaceHolder('COMMENTS', number_format($article['comments'])); $imageList = glob($settings['fsRoot'].'articleImages/' . $article['id'] . '-*-thumb.jpg'); $gridRowDisplay->addPlaceHolder('IMAGE', count($imageList) != 0 ? 'thumb' : ''); $gridRowDisplay->addPlaceHolder('EXCERPT', strip_tags(stripslashes(substr($article['text'], 0, 300))) . ' ...read joke'); $gridHtml .= $gridRowDisplay->outputHtml(true); $gridRowDisplay->reset(); } $gridDisplay->addPlaceHolder('CONTENT', $gridHtml); $itemTypeDisplay->addPlaceHolder('CONTENT', $gridDisplay->outputHtml(true) . "\t\t\t\t\t\t\t\t" . $pagination->GetPageLinks()); } $content = $itemTypeDisplay->outputHtml(true); } else { $articleDisplay = new displayManager('jokeDetails'); $article = $database->oneRow($database->prepareSql("SELECT articles.*, itemratings.comments, itemratings.views FROM articles JOIN itemratings ON articles.id=itemratings.itemId WHERE itemratings.itemType='joke' AND articles.id=:articleId", array('articleId' => $_GET['articleId']))); if (!$article) { showError("Invalid item."); } registerView($_GET['articleId'], 'joke', null, &$database); if (loggedIn()) { $addCommentDisplay = new displayManager('addComment'); $addCommentDisplay->addPlaceHolder('COLS', '42'); $addCommentDisplay->addPlaceHolder('ITEMTYPE', 'joke'); $addCommentDisplay->addPlaceHolder('ITEMID', stripslashes($_GET['articleId'])); } else { $addCommentDisplay = new displayManager('addCommentNotLoggedIn'); } $addCommentDisplay->addPlaceHolder('CURRENT_URL', urlencode($_SERVER['REQUEST_URI'])); $articleInfo = $database->oneRow($database->prepareSql("SELECT * FROM itemratings WHERE itemType='joke' AND itemId={$_GET['articleId']}")); $imgHtml = null; $bigImgHtml = 'image'; $imageList = glob($settings['fsRoot'].'articleImages/' . $article['id'] . '-*-thumb.jpg'); if (count($imageList) != 0) { $imageDisplay = new displayManager('articleImage'); $imgNo = 1; $bigImageHtml = null; foreach($imageList as $temp => $image) { $imageDisplay->addPlaceHolder('FULL', "/" . str_replace($settings['fsRoot'], '', $image)); $imageDisplay->addPlaceHolder('THUMB', "/" . str_replace($settings['fsRoot'], '', str_replace('-thumb', '', $image))); $imgHtml .= $imageDisplay->outputHtml(true); $imageDisplay->reset(); $imgNo++; } $bigImgHtml = 'image'; unset($imageDisplay); } $sqlId = $database->prepareSql("SELECT DISTINCT itemcomments.id, itemcomments.userId, itemcomments.timestamp, itemcomments.comment, authentication.displayName, authentication.profileName FROM itemcomments JOIN authentication ON itemcomments.userId=authentication.userId WHERE itemcomments.itemType='joke' AND itemcomments.itemId={$article['id']} ORDER BY itemcomments.id ASC LIMIT 10"); $comments = $database->multipleRows($sqlId); if (!$comments) { $errorDisplay = new displayManager('error'); $errorDisplay->addPlaceHolder('ERROR', "There are no comments on this item."); $commentHtml = $errorDisplay->outputHtml(true); } else { $commentDisplay = new displayManager('comment'); $commentHtml = null; foreach($comments as $temp => $comment) { $commentDisplay->addPlaceHolder('COMMENT_ID', $comment['id']); $commentDisplay->addPlaceHolder('PROFILENAME', stripslashes($comment['profileName'])); $commentDisplay->addPlaceHolder('DISPLAYNAME', stripslashes($comment['displayName'])); $commentDisplay->addPlaceHolder('SIGNATURE', getSignature($comment['userId'], &$database)); $commentDisplay->addPlaceHolder('COMMENT', htmlentities(stripslashes($comment['comment']))); $commentDisplay->addPlaceHolder('DATE', date('F j, y g:ia', $comment['timestamp'])); $commentDisplay->addPlaceHolder('AVATAR', getAvatar($comment['userId'], 64)); $commentHtml .= $commentDisplay->outputHtml(true); $commentDisplay->reset(); } if ($article['comments'] > 10) { $commentHtml .= "

Showing only the ten most recent comments. Show all comments.

"; } } /******** ARTICLE TAG CLOUD *+* 0000184 20070709 5:54P ********/ require_once("./tagcloud_article.inc.wik"); if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'viewJoke.wik') && !strpos($_SERVER['HTTP_REFERER'], 'articleId')) { $backUrl = $_SERVER['HTTP_REFERER']; } else { $backUrl = "/viewJoke.wik"; } $articleDisplay->addPlaceHolder('BACKNAME', 'Jokes'); $articleDisplay->addPlaceHolder('BACKURL', $backUrl); $articleDisplay->addPlaceHolder('ADD_COMMENT', $addCommentDisplay->outputHtml(true)); $articleDisplay->addPlaceHolder('BIG_IMAGE', $bigImgHtml); $articleDisplay->addPlaceHolder('ITEMTYPE', 'joke'); $articleDisplay->addPlaceHolder('ITEMID', stripslashes($_GET['articleId'])); $articleDisplay->addPlaceHolder('IMAGES', $imgHtml); $articleDisplay->addPlaceHolder('COMMENT_COUNT', number_format($article['comments'])); $articleDisplay->addPlaceHolder('COMMENTS', $commentHtml); $articleDisplay->addPlaceHolder('VIEWS', number_format($article['views'])); $articleDisplay->addPlaceHolder('TITLE', stripslashes($article['title'])); $articleDisplay->addPlaceHolder('DATE', '' . date('F j, Y', $article['timestamp']) . ''); $articleDisplay->addPlaceHolder('ARTICLE', stripslashes($article['text'])); $itemTypeDisplay->addPlaceHolder('CONTENT', $articleDisplay->outputHtml(true)); $content = $itemTypeDisplay->outputHtml(true); $breadcrumb[stripslashes($article['title'])] = $_SERVER['REQUEST_URI']; } $display->addPlaceHolder('CONTENT', $content); /******** LOGIN PANEL *+* 0000181 20070531 4:41 ********/ require_once("./loginBox.inc.wik"); /******** LOGIN STATUS *+* 0000191 20070709 1:58P ********/ require_once("./loginStatus.inc.wik"); outputTemplate(&$display); ?>