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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
<?php
/**
* @version $Revision: 1.4 $
* @package liberty
* @subpackage plugins_data
*/
// +----------------------------------------------------------------------+
// | Copyright (c) 2005, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt 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)
// | by: wjames5
// | Reworked from: data.articles.php from wikiplugin_articles.php
// +----------------------------------------------------------------------+
// $Id: data.blog.php,v 1.4 2006/04/06 05:06:11 starrrider Exp $
/**
* definitions
*/
global $gBitSystem, $gBitSmarty;
if( $gBitSystem->isPackageActive( 'blogs' ) ) { // Do not include this Plugin if the Package is not active
define( 'PLUGIN_GUID_DATABLOG', 'datablog' );
global $gLibertySystem;
$pluginParams = array (
'tag' => 'BLOG',
'auto_activate' => TRUE,
'requires_pair' => FALSE,
'load_function' => 'data_blog',
'help_function' => 'data_blog_help',
'title' => 'Blog',
'help_page' => 'DataPluginBlog',
'description' => tra( "This plugin will display several posts from a blog." ),
'syntax' => "{BLOG id= max= format= }",
'path' => LIBERTY_PKG_PATH.'plugins/data.blog.php',
'security' => 'registered',
'plugin_type' => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATABLOG, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATABLOG );
// Help Routine
function data_blog_help() {
$help =
'<table class="data help">'
.'<tr>'
.'<th>' . tra( "Key" ) . '</th>'
.'<th>' . tra( "Type" ) . '</th>'
.'<th>' . tra( "Comments" ) . '</th>'
.'</tr>'
.'<tr class="even">'
.'<td>id</td>'
.'<td>' . tra( "topic name") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Filters for the specified Blog by id") . '</td>'
.'</tr>'
.'<tr class="odd">'
.'<td>max</td>'
.'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "The number of posts to be displayed. (Default = 3)") . '</td>'
.'</tr>'
.'<tr class="even">'
.'<td>format</td>'
.'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Specify format for posts display - options: full, list (default)") . '</td>'
.'</tr>'
.'</table>'
. tra("Example: ") . "{BLOG id=2 max=5 format='full'}<br />"
. tra("Example: ") . "{BLOG id=5 format='list'}";
return $help;
}
// Executable Routine
function data_blog($data, $params) { // No change in the parameters with Clyde
// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
global $gLibertySystem, $gBitSmarty;
$pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATABLOG];
require_once( BLOGS_PKG_PATH.'BitBlog.php');
require_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
$module_params = $params;
/* $gBitSystem->verifyPermission( 'bit_p_read_blog' ); */
$gBitSmarty->assign('blog_id', $module_params['id']);
$blogPost = new BitBlogPost();
$sortOptions = array(
"last_modified_asc",
"last_modified_desc",
"created_asc",
"created_desc",
);
if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
$sort_mode = $module_params['sort_mode'];
} else {
$sort_mode = 'last_modified_desc';
}
$getHash = Array();
$getHash['blog_id'] = empty($module_params['id']) ? 1 : $module_params['id'];
$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'];
$display_result = "";
switch( $display_format ) {
case 'full':
$display_result = '<div class="blogs">';
$gBitSmarty->assign( 'showDescriptionsOnly', TRUE );
foreach( $blogPosts['data'] as $aPost ) {
$gBitSmarty->assign('aPost', $aPost);
$display_result .= $gBitSmarty->fetch( 'bitpackage:blogs/blog_list_post.tpl' );
/*
$gBitSmarty->assign( 'article', $article );
$display_result .= $gBitSmarty->fetch( 'bitpackage:articles/article_display.tpl' );
*/
}
$display_result .= '</div>';
$display_result = eregi_replace( "\n", "", $display_result );
break;
case 'list':
default:
$display_result = "<ul>";
foreach( $blogPosts['data'] as $post ) {
$link = $blogPost->getDisplayLink( $post['title'], $post );
$display_result .= "<li>$link</li>\n";
}
$display_result .= "</ul>\n";
break;
}
return $display_result;
}
}
?>
|