SetLinksFormat( 'Back', ' | ', 'Next' ); $pagination->SetItemsPerPage(30); $pagination->SetLinksToDisplay(5); if (isset($_GET['page']) && is_numeric($_GET['page'])) { $pagination->SetCurrentPage($_GET['page']); } else { $pagination->SetCurrentPage(1); } $breadcrumb['Page ' . $pagination->currentPage] = "/viewRecipe.wik?page=" . $pagination->currentPage; // B*+* 0000201 20070716 4:21P $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 recipes WHERE type='w'"))); #$sqlId = $database->prepareSql("SELECT DISTINCT recipes.title, recipes.id, recipes.timestamp, recipes.text, itemratings.views, itemratings.comments FROM recipes JOIN itemratings ON recipes.id=itemratings.itemId WHERE itemratings.itemType='recipe' AND recipes.type = 'w' " . $sort . " " . $pagination->GetSqlLimit()); $pagination->setItemCount($database->oneField($database->prepareSql("SELECT COUNT(*) FROM articles WHERE type='r' AND approved='1' AND articles.category1='". $_GET['category'] ."' OR articles.category2='". $_GET['category'] ."' OR articles.category3='". $_GET['category'] ."'"))); $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 type='r' AND articles.approved='1' AND itemratings.itemType='recipe' AND articles.category1='". $_GET['category'] ."' OR articles.category2='". $_GET['category'] ."' OR articles.category3='". $_GET['category'] ."' " . $sort . " " . $pagination->GetSqlLimit()); // E*+* 0000202 20070717 3:04P // E*+* 0000201 20070716 4:21P $recipes = $database->multipleRows($sqlId); if (!$recipes) { $errorDisplay = new displayManager('error2'); $errorDisplay->addPlaceHolder('ERROR', "There are no recipes on this page.."); $itemTypeDisplay->addPlaceHolder('CONTENT', $errorDisplay->outputHtml(true)); } else { $gridDisplay = new displayManager('recipeGridHeader'); $gridRowDisplay = new displayManager('recipeGridRow'); $gridHtml = null; foreach($recipes as $temp => $recipe) { $gridRowDisplay->addPlaceHolder('TITLE', stripslashes($recipe['title'])); $gridRowDisplay->addPlaceHolder('ITEMID', $recipe['id']); $gridRowDisplay->addPlaceHolder('ITEMTYPE', 'gossip'); $gridRowDisplay->addPlaceHolder('DATE', date('F j, y', $recipe['timestamp'])); $gridRowDisplay->addPlaceHolder('VIEWS', number_format($recipe['views'])); $gridRowDisplay->addPlaceHolder('COMMENTS', number_format($recipe['comments'])); $imageList = glob($settings['fsRoot'].'recipeImages/' . $recipe['id'] . '-*-thumb.jpg'); $gridRowDisplay->addPlaceHolder('IMAGE', count($imageList) != 0 ? 'thumb' : ''); $gridRowDisplay->addPlaceHolder('EXCERPT', strip_tags(stripslashes(substr($recipe['text'], 0, 300))) . ' ...read recipe'); $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 if (isset($_GET['recipeId']) && is_numeric($_GET['recipeId'])) { $recipeDisplay = new displayManager('recipeDetails'); $recipe = $database->oneRow($database->prepareSql("SELECT articles.*, itemratings.comments, itemratings.views FROM articles JOIN itemratings ON articles.id=itemratings.itemId WHERE itemratings.itemType='recipe' AND articles.id=:recipeId", array('recipeId' => $_GET['recipeId']))); if (!$recipe) { showError("Invalid item."); } registerView($_GET['recipeId'], 'recipe', null, &$database); if (loggedIn()) { $addCommentDisplay = new displayManager('addComment'); $addCommentDisplay->addPlaceHolder('COLS', '42'); $addCommentDisplay->addPlaceHolder('ITEMTYPE', 'recipe'); $addCommentDisplay->addPlaceHolder('ITEMID', stripslashes($_GET['recipeId'])); } else { $addCommentDisplay = new displayManager('addCommentNotLoggedIn'); } $addCommentDisplay->addPlaceHolder('CURRENT_URL', urlencode($_SERVER['REQUEST_URI'])); $recipeInfo = $database->oneRow($database->prepareSql("SELECT * FROM itemratings WHERE itemType='recipe' AND itemId={$_GET['recipeId']}")); $imgHtml = null; $bigImgHtml = 'image'; $imageList = glob($settings['fsRoot'].'recipeImages/' . $recipe['id'] . '-*-thumb.jpg'); if (count($imageList) != 0) { $imageDisplay = new displayManager('recipeImage'); $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='recipe' AND itemcomments.itemId={$recipe['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('COMMENT', htmlentities(stripslashes($comment['comment']))); $commentDisplay->addPlaceHolder('SIGNATURE', getSignature($comment['userId'], &$database)); $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 ($recipe['comments'] > 10) { $commentHtml .= "

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

"; } } /******** ARTICLE TAG CLOUD *+* 0000184 20070709 5:54P ********/ require_once("./tagcloud_recipe.inc.wik"); if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'viewRecipe.wik') && !strpos($_SERVER['HTTP_REFERER'], 'recipeId')) { $backUrl = $_SERVER['HTTP_REFERER']; } else { $backUrl = "/viewRecipe.wik"; } $recipeDisplay->addPlaceHolder('BACKNAME', 'Recipes'); $recipeDisplay->addPlaceHolder('BACKURL', $backUrl); $recipeDisplay->addPlaceHolder('ADD_COMMENT', $addCommentDisplay->outputHtml(true)); $recipeDisplay->addPlaceHolder('BIG_IMAGE', $bigImgHtml); $recipeDisplay->addPlaceHolder('ITEMTYPE', 'recipe'); $recipeDisplay->addPlaceHolder('ITEMID', stripslashes($_GET['recipeId'])); $recipeDisplay->addPlaceHolder('IMAGES', $imgHtml); $recipeDisplay->addPlaceHolder('COMMENT_COUNT', number_format($recipe['comments'])); $recipeDisplay->addPlaceHolder('COMMENTS', $commentHtml); $recipeDisplay->addPlaceHolder('VIEWS', number_format($recipe['views'])); $recipeDisplay->addPlaceHolder('TITLE', stripslashes($recipe['title'])); $recipeDisplay->addPlaceHolder('DATE', date('F j, Y', $recipe['timestamp'])); $recipeDisplay->addPlaceHolder('ARTICLE', stripslashes($recipe['text'])); $itemTypeDisplay->addPlaceHolder('CONTENT', $recipeDisplay->outputHtml(true)); $content = $itemTypeDisplay->outputHtml(true); $breadcrumb[stripslashes($recipe['title'])] = $_SERVER['REQUEST_URI']; } else { $categoryDisplay = new displayManager('recipeCategories'); /* $categories = array ( 'Vintage' => 16, 'NewSoca' => 17, 'Soca' => 18, 'Pan' => 19, 'Reggae' => 20, 'Chutney' => 21, 'HipHop' => 22, 'RnB' => 23, 'Latin' => 25, 'Parang' => 26, 'Bollywood' => 27, 'Carnival' => 28, 'Places' => 29, 'YourMusic' => 24 ); #require('tags.wik'); #$tagging = new recipeTagging(&$database); foreach($categories as $name => $id) { $countTotal = $database->oneField($database->prepareSql("SELECT COUNT(*) FROM recipes WHERE categoryId=$id")); $countToday = $database->oneField($database->prepareSql("SELECT COUNT(*) FROM recipes WHERE categoryId=$id AND added > " . (time() - 86400))); $categoryDisplay->addPlaceHolder(strtoupper($name) . '_TOTAL', $countTotal); // $categoryDisplay->addPlaceHolder(strtoupper($name) . '_TODAY', $countToday); $tagHtml = null; /* // *_* 0000192 20070710 1:24P $tags = $tagging->getCategoryTags($id, 4); if ($tags) { #$totalTags = null; #$totalTags = join('~|~', $tags); #echo trim(substr($totalTags, 0, 30), '~|') . '
'; #echo '
' . print_r(explode('~|~', substr($totalTags, 0, 10)), true) . '
'; // *_* 0000192 20070710 1:11P //foreach(explode('~|~', substr($totalTags, 0, 20)) as $tag) { foreach($tags as $tag) { //$tagHtml .= "" . stripslashes($tag) . " "; // *_* 0000192 20070709 12:30P Rowena $tagHtml .= "" . stripslashes($tag) . " "; } } */ /* $categoryDisplay->addPlaceHolder(strtoupper($name) . '_TAGS', $tagHtml); } */ $recipeContent = $categoryDisplay->outputHtml(true); $content = $itemTypeDisplay->addPlaceHolder('CONTENT', $recipeContent); $content = $itemTypeDisplay->outputHtml(true); } $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); ?>