Source for file data.articles.php
Documentation is available at data.articles.php
* @subpackage plugins_data
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, 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)
// | by: StarRider <starrrider@users.sourceforge.net>
// | Reworked from: wikiplugin_articles.php - see deprecated code below
// +----------------------------------------------------------------------+
global $gBitSystem, $gBitSmarty;
define( 'PLUGIN_GUID_DATAARTICLES', 'dataarticles' );
'auto_activate' => FALSE,
'requires_pair' => FALSE,
'load_function' => 'data_articles',
'help_function' => 'data_articles_help',
'help_page' => 'DataPluginArticles',
'description' => tra( "This plugin will display several Articles." ),
'syntax' => "{ARTICLES max= topic= type= }",
'<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( "The number of Articles to be displayed. (Default = 3)") . '</td>'
. '<td>' . tra( "topic name") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Filters the Articles so that only the Topic specified is displayed") . '</td>'
. '<td>' . tra( "type name") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Filters the Articles so that only the Type specified is displayed") . '</td>'
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Specify format for article display - options: full, list (default)") . '</td>'
. tra("Example: ") . "{ARTICLES max=5 topic='some_topic'}<br />"
. tra("Example: ") . "{ARTICLES max=5 type='some_type'}";
function data_articles($data, $params) { // No change in the parameters with Clyde
global $gLibertySystem, $gBitSmarty, $gBitSystem;
if( $gBitSystem->isPackageActive( 'articles' ) ) { // Do not include this Plugin if the Package is not active
// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
require_once( ARTICLES_PKG_PATH. 'BitArticle.php');
$module_params = $params;
$stati = array( 'pending', 'approved' );
if( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) {
$status_id = ARTICLE_STATUS_APPROVED;
if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
$sort_mode = $module_params['sort_mode'];
$sort_mode = 'last_modified_desc';
$getHash['status_id'] = $status_id;
$getHash['sort_mode'] = $sort_mode;
$getHash['max_records'] = empty( $module_params['max'] ) ? 1 : $module_params['max'];
if( isset ( $module_params['topic'] )) {
$getHash['topic'] = !empty( $module_params['topic'] ) ? $module_params['topic'] : NULL;
if( isset ( $module_params['topic_id'] )) {
$getHash['topic_id'] = $module_params['topic_id'];
$articles_results = $articlesObject->getList( $getHash );
$display_format = empty( $module_params['format'] ) ? 'simple_title_list' : $module_params['format'];
switch( $display_format ) {
$display_result = '<div class="articles">';
$gBitSmarty->assign( 'showDescriptionsOnly', TRUE );
foreach( $articles_results as $article ) {
$gBitSmarty->assign( 'article', $article );
$gBitSmarty->assign( 'gContent', $articlesObject );
$display_result .= $gBitSmarty->fetch( 'bitpackage:articles/article_display.tpl' );
$display_result .= '</div>';
$display_result = "<ul>";
foreach( $articles_results as $article ) {
$link = $articlesObject->getdisplaylink( $article['title'], $article );
$display_result .= "<li>$link</li>\n";
$display_result .= "</ul>\n";
return "<div class=error>The articles package is not active.</div>";
|