1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
/**
* @version $Header$
* @package blogs
* @subpackage functions
*
* @copyright Copyright (c) 2004-2006, bitweaver.org
* All Rights Reserved. See below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
*/
/**
* required setup
*/
namespace Bitweaver\Liberty;
use Bitweaver\KernelTools;
use Bitweaver\Blogs\BitBlogPost;
require_once BLOGS_PKG_INCLUDE_PATH.'lookup_blog_inc.php';
$gBitSystem->verifyPackage( 'blogs' );
$displayHash = [ 'perm_name' => $gContent->mViewContentPerm ];
$gContent->invokeServices( 'content_display_function', $displayHash );
if( isset($_REQUEST['user_id']) && !isset( $_REQUEST['blog_id'] ) ) {
// We will try and grab the first blog owned by the user id given
$blogsList = $gContent->getList( $_REQUEST );
if (!empty($blogsList[0]['blog_id'])) {
$_REQUEST['blog_id'] = $blogsList[0]['blog_id'];
}
}
if( !$gContent->isValid() ) {
$gBitSystem->setHttpStatus( 404 );
$gBitSystem->fatalError( KernelTools::tra( 'No blog indicated' ));
}
$gContent->verifyViewPermission();
/**
* i don't think this is in use anymore - xing - Thursday Nov 08, 2007 21:49:22 CET
if( $gContent->getField( 'blog_style' ) && $gBitSystem->getConfig('users_themes') == 'h' ) {
$gBitThemes->setStyle( $gContent->getField( 'blog_style' ) );
$gBitThemes->mStyles['styleSheet'] = $gBitSystem->getStyleCss( $gContent->getField( 'blog_style' ), $gContent->getField( 'user_id' ) );
$gBitSmarty->assign( 'userStyle', $gContent->getField( 'blog_style' ) );
}
*/
if( !$gContent->hasUpdatePermission() ) {
$gContent->addHit();
}
$now = $gBitSystem->getUTCTime();
$blogPost = new BitBlogPost();
$listHash = $_REQUEST;
$listHash['blog_id'] = $gContent->getField( 'blog_id' );
$listHash['parse_data'] = true;
$listHash['max_records'] = $gContent->getField( 'max_posts' );
$listHash['load_num_comments'] = true;
$blogPosts = $blogPost->getList( $listHash );
if( count( $blogPosts ) ) {
// If there're more records then assign next_offset
$gBitSmarty->assign('blogPosts', $blogPosts);
$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] );
} elseif( $gContent->hasPostPermission() ) {
KernelTools::bit_redirect( BLOGS_PKG_URL.'post.php?blog_id='.$gContent->getField( 'blog_id' ) );
}
if( $gBitSystem->isFeatureActive( 'users_watches' ) ) {
if( $gBitUser->isValid() && isset( $_REQUEST['watch_event'] ) ) {
if ($_REQUEST['watch_action'] == 'add') {
$blogPost = new BitBlogPost( $_REQUEST['watch_object'] );
if( $blogPost->load() ) {
$gBitUser->storeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'], KernelTools::tra('blog'), $blogPost->getTitle(), $blogPost->getDisplayUrl() );
}
} else {
$gBitUser->expungeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'] );
}
}
$gBitSmarty->assign('user_watching_blog', 'n');
if ( $watch = $gBitUser->getEventWatches( 'blog_post', $listHash['blog_id'] ) ) {
$gBitSmarty->assign('user_watching_blog', 'y');
}
}
$gBitSmarty->assign('descriptionLength', $gBitSystem->getConfig( 'blog_posts_description_length', 500 ) );
$gBitSmarty->assign('showDescriptionsOnly', true);
if ( $gBitSystem->isFeatureActive( 'blog_ajax_more' ) && $gBitThemes->isJavascriptEnabled() ){
$gBitSmarty->assign('ajax_more', true);
$gBitThemes->loadAjax( 'mochikit', [ 'Iter.js', 'DOM.js', 'Style.js', 'Color.js', 'Position.js', 'Visual.js' ] );
}
if( $gContent->isValid() ) {
$gBitSystem->setCanonicalLink( $gContent->getDisplayUrl() );
}
// Display the template
$gBitSystem->display( 'bitpackage:blogs/view_blog.tpl', $gContent->getTitle() , [ 'display_mode' => 'display' ] );
|