From c915e19e9c30d2e08115b6e21c93d8dc2539b5f7 Mon Sep 17 00:00:00 2001 From: Max Kremmel Date: Tue, 8 Jul 2008 06:54:18 +0000 Subject: move some plugins to their new homes --- liberty_plugins/data.article.php | 103 +++++++++++++++++++++++++ liberty_plugins/data.articles.php | 155 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 liberty_plugins/data.article.php create mode 100644 liberty_plugins/data.articles.php (limited to 'liberty_plugins') diff --git a/liberty_plugins/data.article.php b/liberty_plugins/data.article.php new file mode 100644 index 0000000..f8a0ddf --- /dev/null +++ b/liberty_plugins/data.article.php @@ -0,0 +1,103 @@ + see http://phpdocu.sourceforge.net/ +// +----------------------------------------------------------------------+ +// | Author (TikiWiki): dheltzel +// | Reworked for Bitweaver (& Undoubtedly Screwed-Up) +// | by: StarRider +// | Reworked from: wikiplugin_article.php - see deprecated code below +// +----------------------------------------------------------------------+ +// $Id: data.article.php,v 1.1 2008/07/08 06:54:17 squareing Exp $ + +/** + * definitions + */ +global $gBitSystem; +if( $gBitSystem->isPackageActive( 'articles' ) ) { // Do not include this Plugin if the Package is not active +define( 'PLUGIN_GUID_DATAARTICLE', 'dataarticle' ); +global $gLibertySystem; +$pluginParams = array ( + 'tag' => 'ARTICLE', + 'auto_activate' => FALSE, + 'requires_pair' => FALSE, + 'load_function' => 'data_article', + 'title' => 'Article - This plugin is not yet functional.', // Remove this line when the plugin +// 'title' => 'Article', // and Remove the comment from the start of this line + 'help_page' => 'DataPluginArticle', + 'description' => tra("This plugin will display the data from a single field in the specified Article."), + 'help_function' => 'data_article_help', + 'syntax' => "{ARTICLE id= field=}", + 'path' => LIBERTY_PKG_PATH.'plugins/data.article.php', + 'security' => 'registered', + 'plugin_type' => DATA_PLUGIN +); +$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLE, $pluginParams ); +$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLE ); + +// Help Routine +function data_article_help() { + $help = + '' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'
' . tra( "Key" ) . '' . tra( "Type" ) . '' . tra( "Comments" ) . '
id' . tra( "numeric") . '
' . tra("(required)") . '
' . tra( "The Id number of the Article. This value can easily be found in the URL when the Article is displayed.") . '
field' . tra( "string") . '
' . tra("(optional)") . '
' . tra( "This can be any field found in the") . ' articles ' . tra("table.") . '
' + . tra("This includes (in order of usefulnes):") . 'title, heading, body, author, size, reads, votes, points, type and rating' . '
' + . tra("Example: ") . "{ARTICLE id=14 field='heading'}"; + return $help; +} + +// Executable Routine +function data_article($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; + $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLE]; + $ret = 'The plugin "' . $pluginParams['tag'] . '" has not been completed as yet. '; + return $ret; +} +} +/****************************************************************************** +The code below is from the deprecated ARTICLE plugin. All comments and the help routines have been removed. - StarRider + +global $gBitSystem; +if( $gBitSystem->isPackageActive( 'articles' ) ) { + include_once( ARTICLES_PKG_PATH . 'art_lib.php' ); + + function wikiplugin_article($data, $params) { + global $artlib; + extract ($params, EXTR_SKIP); + if (!isset($id)) { + return ("The plugin Article needs an article ID to function.
"); + } + if (!isset($field)) { + $field = 'heading'; + } + $article_data = $artlib->get_article($id); + return $article_data[$field]; + } +} +*/ +?> diff --git a/liberty_plugins/data.articles.php b/liberty_plugins/data.articles.php new file mode 100644 index 0000000..deca97f --- /dev/null +++ b/liberty_plugins/data.articles.php @@ -0,0 +1,155 @@ + 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: data.articles.php,v 1.1 2008/07/08 06:54:18 squareing Exp $ + +/** + * definitions + */ +global $gBitSystem, $gBitSmarty; +define( 'PLUGIN_GUID_DATAARTICLES', 'dataarticles' ); +global $gLibertySystem; +$pluginParams = array ( + 'tag' => 'ARTICLES', + 'auto_activate' => FALSE, + 'requires_pair' => FALSE, + 'load_function' => 'data_articles', + 'help_function' => 'data_articles_help', + 'title' => 'Articles', + 'help_page' => 'DataPluginArticles', + 'description' => tra( "This plugin will display several Articles." ), + 'syntax' => "{ARTICLES max= topic= type= }", + 'path' => LIBERTY_PKG_PATH.'plugins/data.articles.php', + 'security' => 'registered', + 'plugin_type' => DATA_PLUGIN +); +$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLES, $pluginParams ); +$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLES ); + +// Help Routine +function data_articles_help() { + $help = + '' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'' + .'
' . tra( "Key" ) . '' . tra( "Type" ) . '' . tra( "Comments" ) . '
max' . tra( "numeric") . '
' . tra("(optional)") . '
' . tra( "The number of Articles to be displayed. (Default = 3)") . '
topic' . tra( "topic name") . '
' . tra("(optional)") . '
' . tra( "Filters the Articles so that only the Topic specified is displayed") . '
type' . tra( "type name") . '
' . tra("(optional)") . '
' . tra( "Filters the Articles so that only the Type specified is displayed") . '
format' . tra( "string") . '
' . tra("(optional)") . '
' . tra( "Specify format for article display - options: full, list (default)") . '
' + . tra("Example: ") . "{ARTICLES max=5 topic='some_topic'}
" + . 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( ARTICLES_PKG_PATH.'BitArticle.php'); + require_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' ); + + $module_params = $params; + $articlesObject = new BitArticle(); + $stati = array( 'pending', 'approved' ); + if( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) { + $status_id = constant( 'ARTICLE_STATUS_'.strtoupper( $module_params['status'] ) ); + } else { + $status_id = ARTICLE_STATUS_APPROVED; + } + + $sortOptions = array( + "last_modified_asc", + "last_modified_desc", + "created_asc", + "created_desc", + "random", + ); + 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['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 = eregi_replace( "\n", "", $display_result ); + break; + case 'list': + default: + $display_result = "
    "; + foreach( $articles_results as $article ) { + $link = $articlesObject->getdisplaylink( $article['title'], $article ); + $display_result .= "
  • $link
  • \n"; + } + $display_result .= "
\n"; + break; + } + return $display_result; + } else { + return "
The articles package is not active.
"; + } +} +?> -- cgit v1.3