Source for file data.blog.php
Documentation is available at data.blog.php
* @subpackage plugins_data
// +----------------------------------------------------------------------+
// | Copyright (c) 2005, 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
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author (TikiWiki): Gustavo Muslera <gmuslera@users.sourceforge.net>
// | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
// | Reworked from: data.articles.php from wikiplugin_articles.php
// +----------------------------------------------------------------------+
global $gBitSystem, $gBitSmarty;
//it seems this is loaded before the package is activated.
//if( $gBitSystem->isPackageActive( 'blogs' ) ) { // Do not include this Plugin if the Package is not active
define( 'PLUGIN_GUID_DATABLOG', 'datablog' );
'auto_activate' => FALSE,
'requires_pair' => FALSE,
'load_function' => 'data_blog',
'help_function' => 'data_blog_help',
'help_page' => 'DataPluginBlog',
'description' => tra( "This plugin will display several posts from a blog." ),
'syntax' => "{BLOG id= user= max= format= }",
'<table class="data help">'
. '<th>' . tra( "Key" ) . '</th>'
. '<th>' . tra( "Type" ) . '</th>'
. '<th>' . tra( "Comments" ) . '</th>'
. '<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Filters for the specified Blog by id") . '</td>'
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "The login name of the user who's posts are to be displayed. (Default = 3)") . '</td>'
. '<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "The number of posts to be displayed. (Default = 3)") . '</td>'
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Specify format for posts display - options: full, list (default)") . '</td>'
. tra("Example: ") . "{BLOG id=2 max=5 format='full'}<br />"
. tra("Example: ") . "{BLOG id=5 format='list'}";
function data_blog($data, $params) { // No change in the parameters with Clyde
global $gLibertySystem, $gBitSmarty, $gBitSystem, $gBitUser;
if ($gBitSystem->isPackageActive('blogs') && $gBitUser->hasPermission( 'p_blogs_view')) {
// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
require_once( BLOGS_PKG_PATH. 'BitBlog.php');
$module_params = $params;
if (isset ($module_params['id'])) {
$gBitSmarty->assign('blog_id', $module_params['id']);
if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
$sort_mode = $module_params['sort_mode'];
$sort_mode = 'publish_date_desc';
if ( isset ($module_params['user']) ){ $getHash['user'] = $module_params['user']; }
if ( isset ($module_params['id']) ){ $getHash['blog_id'] = $module_params['id'];}
if ( isset ($module_params['group_id']) ){ $getHash['group_id'] = $module_params['group_id'];}
if ( isset ($module_params['role_id']) ){ $getHash['role_id'] = $module_params['role_id'];}
$getHash['enforce_status'] = TRUE;
// @TODO enable lists that include draft posts
// the current tpl configuration doesnt allow us to support draft lists right now
// there is an object reference problem in liberty::service_content_body_inc.tpl
// if the object reference problem in the above mentions tpl is patched then use this if to enable drafts
// if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){
// if we are getting drafts then get future posts too
$getHash['show_future'] = TRUE;
$getHash['min_status_id'] = - 6;
$getHash['max_status_id'] = - 4;
$getHash['min_owner_status_id'] = - 6;
$getHash['user_id'] = $gBitUser->mUserId;
$getHash['min_owner_status_id'] = 0;
$getHash['sort_mode'] = $sort_mode;
$getHash['parse_data'] = TRUE;
$getHash['max_records'] = empty($module_params['max']) ? 1 : $module_params['max'];
$getHash['load_num_comments'] = TRUE;
$getHash['page'] = (!empty($module_params['page']) ? $module_params['page'] : 1);
$getHash['offset'] = (!empty($module_params['offset']) ? $module_params['offset'] : 0);
$blogPosts = $blogPost->getList( $getHash );
$display_format = empty($module_params['format']) ? 'simple_title_list' : $module_params['format'];
switch( $display_format ) {
$display_result = '<div class="blogs">';
if ( $gBitSystem->isPackageActive( 'rss' ) ){
if ( isset ($module_params['user']) ){
$rssUser->load(false, $module_params['user']);
$rssUserId = $rssUser->getField('user_id');
$rssPath = BLOGS_PKG_URL. 'blogs_rss.php?'
. ( isset ($module_params['id']) ? 'blog_id='. $module_params['id'] : "" )
. ( (isset ($module_params['id']) && isset ($rssUserId))? "&": "")
. ( isset ($rssUserId) ? 'user_id='. $rssUserId : "" )
. ( (isset ($rssUserId) && isset ($module_params['group_id']))? "&": "")
. ( isset ($module_params['group_id']) ? 'group_id='. $module_params['group_id'] : "" )
. ( (isset ($rssUserId) && isset ($module_params['role_id']))? "&": "")
. ( isset ($module_params['role_id']) ? 'role_id='. $module_params['role_id'] : "" );
// something like this would be better, calling smarty directly so translation can also be called -wjames5
// $rssIcon = smarty_function_biticon( array('ipackage'=>"rss", 'iname'="rss-16x16", 'iexplain'=>"RSS feed"), &$gBitSmarty );
$display_result .= '<div class="floaticon"><a title="RSS feed" href="'. $rssPath. '"><img src="'. BIT_ROOT_URL. 'rss/icons/rss-16x16.png" alt="RSS feed" title="RSS feed" class="icon" /></a></div>';
$gBitSmarty->assign( 'showDescriptionsOnly', TRUE );
foreach( $blogPosts['data'] as $aPost ) {
$gBitSmarty->assign('aPost', $aPost);
$display_result .= $gBitSmarty->fetch( 'bitpackage:blogs/blog_list_post.tpl' );
$display_result .= '</div>';
$display_result = "<ul>";
foreach( $blogPosts['data'] as $post ) {
$link = $blogPost->getDisplayLink( $post['title'], $post );
$display_result .= "<li>$link</li>\n";
$display_result .= "</ul>\n";
$display_result = '<div class=error>'. tra('Blogs Package Deactivated.'). '</div>';
|