function blog_theme_main($area, $category) { global $lang; //Display existing posts. if (blog_get_posts()) { //Load posts in array. $posts = blog_get_posts(); //Get page number if (isset($_GET['p']) && is_numeric($_GET['p'])) { $page_no = $_GET['p']; } else { $page_no = 1; } //Count posts. $post_number = 0; foreach ($posts as $post) { //Only show post if all categories should be shown, or if it's in the given category. if ($category == null || $category == $post['category']) { //Only display post if it's supposed to be on this page. if ($post_number >= ($page_no - 1) * module_get_setting('blog', 'posts_per_page') && $post_number < $page_no * module_get_setting('blog', 'posts_per_page')) { ?> <div class="blog_post"> <p class="blog_post_title"> <a href="<?php echo SITE_URL . '/' . PAGE_URL_PREFIX . CURRENT_PAGE_SEONAME . BLOG_URL_PREFIX . $post['seoname']; ?> " title="<?php echo $post['title']; ?> "><?php echo $post['title']; ?> </a> </p> <span class="blog_post_info"> <?php echo $post['date'] . ' ' . $lang['blog']['at'] . ' ' . $post['time'] . ' ' . $lang['blog']['in'] . ' ' . $post['category']; ?> </span> <div class="blog_post_content"> <?php //Check if we need to truncate if (module_get_setting('blog', 'truncate_posts') != '0') { echo truncate($post['content'], module_get_setting('blog', 'truncate_posts')); } else { run_hook('theme_content', array(&$post['content'])); echo $post['content']; } ?> </div> <?php //If reactions are enabled, count reactions and display in 'read more'-link if (module_get_setting('blog', 'allow_reactions') == 'true') { $number = blog_get_reactions($post['seoname']); if ($number) { $number = count($number); if ($number == 1) { $more_link = $number . ' ' . $lang['blog']['reaction']; } else { $more_link = $number . ' ' . $lang['blog']['reactions']; } } else { $more_link = $lang['blog']['no_reactions']; } } else { $more_link = $lang['blog']['read_more']; } ?> <p class="blog_post_more"> <a href="<?php echo SITE_URL . '/' . PAGE_URL_PREFIX . CURRENT_PAGE_SEONAME . BLOG_URL_PREFIX . $post['seoname']; ?> " title="<?php echo $more_link; ?> ">» <?php echo $more_link; ?> </a> </p> </div> <?php } $post_number++; } } unset($post); //Show page numbers echo '<p>' . $lang['blog']['pages'] . ' '; if ($category == null) { blog_show_page_no_list($page_no); } else { blog_show_page_no_list($page_no, $category); } echo '</p>'; } }
/** * Counts the number of pages we need for pagination of all blog posts. * @param mixed $category Optional, if we need a number of pages for posts in one category. */ function blog_count_pages($category = false) { if (!$category) { $number_posts = count(blog_get_posts()); } else { $posts = blog_get_posts(); $number_posts = 0; foreach ($posts as $post) { if ($post['category'] == $category) { $number_posts++; } } unset($post); } $number_pages = ceil($number_posts / module_get_setting('blog', 'posts_per_page')); return $number_pages; }
function blog_page_admin_blog() { global $cont1, $lang; ?> <p> <strong><?php echo $lang['blog']['main_message']; ?> </strong> </p> <?php showmenudiv($lang['blog']['new_post'], false, 'data/image/newpage.png', '?module=blog&page=newpost', false); ?> <span class="kop2"><?php echo $lang['blog']['posts']; ?> </span> <?php //Display existing posts. if (blog_get_posts()) { //Load posts in array. $posts = blog_get_posts(); foreach ($posts as $post) { ?> <div class="menudiv"> <span> <img src="data/modules/blog/images/blog.png" alt="" /> </span> <span class="title-page"><?php echo $post['title']; ?> </span> <span> <a href="?module=blog&page=editpost&var1=<?php echo $post['seoname']; ?> "> <img src="data/image/edit.png" title="<?php echo $lang['blog']['edit_post']; ?> " alt="<?php echo $lang['blog']['edit_post']; ?> " /> </a> </span> <?php if (blog_get_reactions($post['seoname'])) { ?> <span> <a href="?module=blog&page=editreactions&var1=<?php echo $post['seoname']; ?> "> <img src="data/modules/blog/images/reactions.png" title="<?php echo $lang['blog']['edit_reactions']; ?> " alt="<?php echo $lang['blog']['edit_reactions']; ?> " /> </a> </span> <?php } ?> <span> <a href="?module=blog&page=deletepost&var1=<?php echo $post['seoname']; ?> "> <img src="data/image/delete_from_trash.png" title="<?php echo $lang['blog']['delete_post']; ?> " alt="<?php echo $lang['blog']['delete_post']; ?> " /> </a> </span> <br /> <span> <span style="font-size: 12px; font-style: italic"> <?php //Show post date and category. echo $post['date'] . ' ' . $lang['blog']['at'] . ' ' . $post['time']; if (isset($post['category']) && !empty($post['category'])) { echo ' ' . $lang['blog']['in'] . ' ' . $post['category']; } ?> </span> </span> </div> <?php } } else { echo '<span class="kop4">' . $lang['general']['nothing_yet'] . '</span><br /><br />'; } ?> <span class="kop2"><?php echo $lang['blog']['categories']; ?> </span> <?php //If there already are categories. if (blog_get_categories()) { //Get categories. $categories = blog_get_categories(); //And show them. echo '<div>'; foreach ($categories as $category) { ?> <div class="menudiv"> <span> <img src="data/image/page.png" alt="" /> </span> <span class="title-page"><?php echo $category['title']; ?> </span> <span> <a href="?module=blog&page=deletecategory&var1=<?php echo $category['seoname']; ?> "> <img src="data/image/delete_from_trash.png" alt="<?php echo $lang['blog']['delete_cat']; ?> " title="<?php echo $lang['blog']['delete_cat']; ?> " /> </a> </span> </div> <?php } unset($category); echo '</div>'; } else { echo '<span class="kop4">' . $lang['general']['nothing_yet'] . '</span><br /><br />'; } //New category. ?> <form method="post" action=""> <label class="kop2" for="cont1"><?php echo $lang['blog']['new_cat']; ?> </label> <span class="kop4"><?php echo $lang['blog']['new_cat_message']; ?> </span> <br /> <input name="cont1" id="cont1" type="text" /> <input type="submit" name="Submit" value="<?php echo $lang['general']['save']; ?> " /> </form> <?php //When form is submitted. if (isset($cont1) && !empty($cont1)) { blog_create_category($cont1); redirect('?module=blog', 0); } ?> <p> <a href="?action=modules"><<< <?php echo $lang['general']['back']; ?> </a> </p> <?php }