diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 13:05:44 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 13:05:44 +0100 |
| commit | 132ef7cac27dc1fb194b2c240d90fc42625a44d5 (patch) | |
| tree | 1622dd11ac10456268dd5acc53416166fbb45c05 /rankings.php | |
| parent | 693dd159a5831494f7b118130b5ff75a56f049e9 (diff) | |
| download | blogs-132ef7cac27dc1fb194b2c240d90fc42625a44d5.tar.gz blogs-132ef7cac27dc1fb194b2c240d90fc42625a44d5.tar.bz2 blogs-132ef7cac27dc1fb194b2c240d90fc42625a44d5.zip | |
Fix undefined BITBLOGPOST_CONTENT_TYPE_GUID in rankings.php
Use BitBlogPost instead of LibertyContent so the autoloader loads
BitBlogPost.php (which defines the constant) before it is referenced.
Removed dead commented-out legacy ranking code.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'rankings.php')
| -rwxr-xr-x | rankings.php | 151 |
1 files changed, 5 insertions, 146 deletions
diff --git a/rankings.php b/rankings.php index 11bc2f8..1625597 100755 --- a/rankings.php +++ b/rankings.php @@ -17,7 +17,7 @@ namespace Bitweaver\Blogs; require_once '../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; -use BitWeaver\Liberty\LibertyContent; +use Bitweaver\Blogs\BitBlogPost; $gBitSystem->verifyPackage( 'blogs' ); $gBitSystem->verifyFeature( 'blog_rankings' ); @@ -59,155 +59,14 @@ if( !empty( $_REQUEST['sort_mode'] ) ) { $_REQUEST['attribute'] = KernelTools::tra( 'Hits' ); } +if( empty( $gContent ) ) { + $gContent = new BitBlogPost(); +} + $_REQUEST['title'] = KernelTools::tra( 'Blog Post Rankings' ); $_REQUEST['content_type_guid'] = BITBLOGPOST_CONTENT_TYPE_GUID; $_REQUEST['max_records'] = !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : 10; - -if( empty( $gContent ) ) { - $gContent = new LibertyContent(); -} $rankList = $gContent->getContentRanking( $_REQUEST ); $gBitSmarty->assign( 'rankList', $rankList ); $gBitSystem->display( 'bitpackage:liberty/rankings.tpl', KernelTools::tra( "Blog Post Rankings" ) , [ 'display_mode' => 'display' ]); - -/* ---- below is what blog rankings was - might want to canabalize some of it eventually ---- */ -/* - -require_once '../kernel/includes/setup_inc.php'; - - -$gBitSystem->verifyPackage( 'blogs' ); - -$gBitSystem->verifyFeature( 'blog_rankings' ); - -$gBitSystem->verifyPermission( 'p_blogs_view' ); - -require_once( BLOGS_PKG_PATH . 'BitBlog.php' ); -require_once( BLOGS_PKG_PATH . 'BitBlogPost.php' ); - -$allrankings = array( - array( - 'name' => KernelTools::tra('Most visited blogs'), - 'value' => 'blog_ranking_top_blogs' -), - array( - 'name' => KernelTools::tra('Last posts'), - 'value' => 'blog_ranking_last_posts' -), - /** - * @todo reenable once we have activity implemented - array( - 'name' => KernelTools::tra('Most active blogs'), - 'value' => 'blog_ranking_top_active_blogs' -) - **/ -/* -); - -$gBitSmarty->assign('allrankings', $allrankings); - -if (!isset($_REQUEST["which"])) { - $which = 'blog_ranking_top_blogs'; -} else { - $which = $_REQUEST["which"]; -} - -$gBitSmarty->assign('which', $which); - -// Get the page from the request var or default it to HomePage -if (!isset($_REQUEST["limit"])) { - $limit = 10; -} else { - $limit = $_REQUEST["limit"]; -} - -$gBitSmarty->assign('limit', $limit); - -// Rankings: -// Top Pages -// Last pages -// Top Authors -- Would be nice. -$rankings = []; - -$rankings = $which($limit); - -$gBitSmarty->assign('rankings', $rankings); -$gBitSmarty->assign('rpage', 'rankings.php'); - -// Display the template -$gBitSystem->display( 'bitpackage:blogs/ranking.tpl', KernelTools::tra($rankings['title']), array( 'display_mode' => 'display' )); - -// =============================== some ranking functions - as soon as blogs are part of LibertyContent, we can use LibertyContent::getContentRanking() -function blog_ranking_top_blogs($limit) { - global $gBitSystem; - $list_hash['sort_mode'] = 'lch.hits_desc'; - $list_hash['max_records'] = $limit; - $b = new BitBlog(); - $list = $b->getList($list_hash); - $query = "select p.*, lc.* FROM `".BIT_DB_PREFIX."blog_posts` p LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (p.`content_id` = lc.`content_id`) WHERE p.blog_id = ? ORDER BY p.post_id desc"; - foreach($list['data'] as $key => $blog) { - $result = $gBitSystem->mDb->query($query, array($blog['blog_id']), $gBitSystem->getConfig('blogs_top_post_count', 3)); - - while ($ret = $result->fetchRow()) { - $ret['display_url'] = BitBlogPost::getDisplayUrlFromHash($ret['content_id']); - $list['data'][$key]['post_array'][] = $ret; - } - } - $list['title'] = KernelTools::tra("Most Visited Blogs"); - return $list; -} - -/** TODO: This should be changed when we start using activity in the blog. - We should check TW 1.9 for code for that field in the blog. */ -/* -function blog_ranking_top_active_blogs($limit) { - global $gBitSystem; - $list_hash['sort_mode'] = 'b.activity'; - $list_hash['max_records'] = $limit; - $b = new BitBlog(); - $list = $b->getList($list_hash); - $query = "select p.*, lc.* FROM `".BIT_DB_PREFIX."blog_posts` p LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (p.`content_id` = lc.`content_id`) WHERE p.blog_id = ? ORDER BY p.post_id desc"; - foreach($list['data'] as $key => $blog) { - $result = $gBitSystem->mDb->query($query, array($blog['blog_id']), $gBitSystem->getConfig('blogs_top_post_count', 3)); - - while ($ret = $result->fetchRow()) { - $ret['display_url'] = BitBlogPost::getDisplayUrlFromHash($ret['content_id']); - $list['data'][$key]['post_array'][] = $ret; - } - } - $list['title'] = KernelTools::tra("Most Visited Blogs"); - return $list; -} - -function blog_ranking_last_posts($limit) { - global $gBitSystem; - $list_hash['max_records'] = $limit; - $list_hash['sort_mode'] = 'created_desc'; - $list_hash['max_records'] = $limit; - $bp = new BitBlogPost(); - $posts = $bp->getList($list_hash); - // Extract blog_ids to load the blogs. - foreach( $posts['data'] as $key => $post) { - $blog_ids[$post['blog_id']] = $post['blog_id']; - } - if (!empty($blog_ids)) { - $b = new BitBlog(); - $blog_hash['sort_mode'] = 'lch.hits_desc'; - $blog_hash['find'] = $blog_ids; - $blogs = $b->getList($blog_hash); - $list['data'] = []; - // Reorganize blogs by id - foreach($blogs['data'] as $key => $blog) { - $list['data'][$blog['blog_id']] = $blog; - } - // And merge in posts - foreach($posts['data'] as $key => $post) { - $post['post_url'] = $bp->getDisplayUrl($post['content_id']); - $list['data'][$post['blog_id']]['post_array'][] = $post; - } - } - $list['title'] = 'Last Posts'; - return $list; -} -*/ |
