see http://phpdocu.sourceforge.net/ // +----------------------------------------------------------------------+ // | Author (TikiWiki): Gustavo Muslera // | Reworked for Bitweaver (& Undoubtedly Screwed-Up) // | by: StarRider // | Reworked from: wikiplugin_articles.php - see deprecated code below // +----------------------------------------------------------------------+ // $Id$ namespace Bitweaver\Liberty; use Bitweaver\Articles\BitArticle; use Bitweaver\KernelTools; /** * definitions */ global $gBitSystem, $gBitSmarty; define( 'PLUGIN_GUID_DATAARTICLES', 'dataarticles' ); global $gLibertySystem; $pluginParams = [ 'tag' => 'ARTICLES', 'auto_activate' => false, 'requires_pair' => false, 'load_function' => 'data_articles', 'help_function' => 'data_articles_help', 'title' => 'Articles', 'help_page' => 'DataPluginArticles', 'description' => KernelTools::tra( "This plugin will display several Articles." ), 'syntax' => "{ARTICLES max= topic= type= }", 'plugin_type' => DATA_PLUGIN, ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLES, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLES ); // Help Routine function data_articles_help() { $help = "' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'
" . KernelTools::tra( "Key" ) . '' . KernelTools::tra( "Type" ) . '' . KernelTools::tra( "Comments" ) . '
max' . KernelTools::tra( "numeric") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "The number of Articles to be displayed. (Default = 3)") . '
topic' . KernelTools::tra( "topic name") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Filters the Articles so that only the Topic specified is displayed") . '
type' . KernelTools::tra( "type name") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Filters the Articles so that only the Type specified is displayed") . '
format' . KernelTools::tra( "string") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Specify format for article display - options: full, list (default)") . '
' . KernelTools::tra("Example: ") . "{ARTICLES max=5 topic='some_topic'}
" . KernelTools::tra("Example: ") . "{ARTICLES max=5 type='some_type'}"; return $help; } // Executable Routine 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 $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLES]; require_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' ); $module_params = $params; $articlesObject = new BitArticle(); $stati = [ 'pending', 'approved' ]; $status_id = ( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) ? constant( 'ARTICLE_STATUS_' . strtoupper( $module_params['status'] ) ) : ARTICLE_STATUS_APPROVED; $sortOptions = [ "last_modified_asc", "last_modified_desc", "created_asc", "created_desc", "random", ]; $sort_mode = ( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) ? $module_params['sort_mode'] : 'last_modified_desc'; $getHash = []; $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']; $display_result = ""; switch( $display_format ) { case 'full': $display_result = '
'; $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 .= '
'; $display_result = preg_replace( "/\\\\n/", '', $display_result ); break; case 'list': default: $display_result = "\n"; break; } return $display_result; } return "
The articles package is not active.
"; }