see http://phpdocu.sourceforge.net/ // +----------------------------------------------------------------------+ // | Author (TikiWiki): Mose // | Reworked for Bitweaver by: Christian Fowler // +----------------------------------------------------------------------+ // $Id$ /** * definitions */ define( 'PLUGIN_GUID_DATAMODULE', 'datamodule' ); global $gLibertySystem; $pluginParams = [ 'tag' => 'MODULE', 'auto_activate' => false, 'requires_pair' => false, 'load_function' => '\data_datamodule', 'title' => 'Module', 'help_page' => 'DataPluginModule', 'description' => KernelTools::tra("Display a module block in content"), 'help_function' => '\datamodule_help', 'syntax' => "{module module= align='right'}", 'plugin_type' => DATA_PLUGIN, ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAMODULE, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAMODULE ); function datamodule_help() { $help = '' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'
' . KernelTools::tra( "Key" ) . '' . KernelTools::tra( "Type" ) . '' . KernelTools::tra( "Comments" ) . '
module' . KernelTools::tra( "string" ) . '
' . KernelTools::tra( "(required)" ) . '
' . KernelTools::tra( "Name of module you want to display.") .'
package' . KernelTools::tra( "string" ) . '
' . KernelTools::tra( "(required)" ) . '
' . KernelTools::tra( "Package the module is part of.") .'
rows' . KernelTools::tra( "numeric" ) . '
' . KernelTools::tra( "(optional)" ) . '
' . KernelTools::tra( "Number of rows you wish to show.") .'
' . KernelTools::tra( "Additional arguments and values depend on the selected module." ) .'
' . KernelTools::tra( "Example: " ) . '{MODULE module=last_changes package=liberty title="Recent Changes"}'; return $help; } function data_datamodule( $pData, $pParams ) { global $gBitThemes, $gBitSmarty; $out = ''; $ret = ' '; extract( $pParams , EXTR_SKIP ); if( !empty( $module ) && !empty( $package )) { $modules_dir = constant( strtoupper( $package ).'_PKG_PATH' ).'modules/'; if( is_file( $modules_dir.'mod_'.$module.'.tpl' )) { $tpl = 'bitpackage:'.$package.'/mod_'.$module.'.tpl'; } else { return '
'.KernelTools::tra( "The module / package combination you entered is not valid" ).'
'; } } else { return '
'.KernelTools::tra( "Both paramters 'module' and 'package' are required" ).'
'; } // Setup moduleParams the best we can. $moduleParams = []; $moduleParams['module_params'] = $pParams; $moduleParams['module_rows'] = $pParams['rows'] ?? 10; if( isset( $pParams['title'] )) { $moduleParams['title'] = $pParams['title']; } $gBitSmarty->assign( 'moduleParams', $moduleParams ); if( !$out = $gBitSmarty->fetch( $tpl ) ) { if( $gBitThemes->isCustomModule( $module ) ) { $info = $gBitThemes->getCustomModule( $module ); $gBitSmarty->assign( 'user_title', $info["title"] ); $gBitSmarty->assign( 'user_data', $info["data"] ); $out = $gBitSmarty->fetch( 'modules/user_module.tpl' ); } } $out = preg_replace( "#\n#is", "", $out ); // deal with custom styling $style = ''; $style_options = [ 'float', 'width', 'background', 'color' ]; foreach( $pParams as $param => $value ) { if( in_array( $param, $style_options ) ) { $style .= $param.':'.$value.';'; } } if( !empty( $style ) ) { $style = ' style="'.$style.'"'; } if( $out ) { $ret = ''.$out.''; } return $ret; }