liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.module.php

Documentation is available at data.module.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2004, bitweaver.org
  9. // +----------------------------------------------------------------------+
  10. // | All Rights Reserved. See below for details and a complete list of authors.
  11. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  12. // |
  13. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  14. // | -> see http://phpdocu.sourceforge.net/
  15. // +----------------------------------------------------------------------+
  16. // | Author (TikiWiki): Mose <mose@users.sourceforge.net>
  17. // | Reworked for Bitweaver  by: Christian Fowler <spiderr@users.sourceforge.net>
  18. // +----------------------------------------------------------------------+
  19. // $Id$
  20.  
  21. /**
  22.  * definitions
  23.  */
  24. define'PLUGIN_GUID_DATAMODULE''datamodule' );
  25.  
  26. global $gLibertySystem;
  27. $pluginParams array (
  28.     'tag'           => 'MODULE',
  29.     'auto_activate' => FALSE,
  30.     'requires_pair' => FALSE,
  31.     'load_function' => 'data_datamodule',
  32.     'title'         => 'Module',
  33.     'help_page'     => 'DataPluginModule',
  34.     'description'   => tra("Display a module block in content"),
  35.     'help_function' => 'datamodule_help',
  36.     'syntax'        => "{module module= align='right'}",
  37.     'plugin_type'   => DATA_PLUGIN
  38. );
  39. $gLibertySystem->registerPluginPLUGIN_GUID_DATAMODULE$pluginParams );
  40. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAMODULE );
  41.  
  42. function datamodule_help({
  43.     $help =
  44.         '<table class="data help">'
  45.             .'<tr>'
  46.                 .'<th>' tra"Key" '</th>'
  47.                 .'<th>' tra"Type" '</th>'
  48.                 .'<th>' tra"Comments" '</th>'
  49.             .'</tr>'
  50.             .'<tr class="odd">'
  51.                 .'<td>module</td>'
  52.                 .'<td>' tra"string" '<br />' tra"(required)" '</td>'
  53.                 .'<td>' tra"Name of module you want to display.")
  54.             .'</tr>'
  55.             .'<tr class="even">'
  56.                 .'<td>package</td>'
  57.                 .'<td>' tra"string" '<br />' tra"(required)" '</td>'
  58.                 .'<td>' tra"Package the module is part of.")
  59.             .'</tr>'
  60.             .'<tr class="even">'
  61.                 .'<td>rows</td>'
  62.                 .'<td>' tra"numeric" '<br />' tra"(optional)" '</td>'
  63.                 .'<td>' tra"Number of rows you wish to show.")
  64.             .'</tr>'
  65.             .'<tr class="odd">'
  66.                 .'<td colspan="3">' tra"Additional arguments and values depend on the selected module." )
  67.             .'</tr>'
  68.         .'</table>'
  69.         . tra"Example: " '{MODULE module=last_changes package=liberty title="Recent Changes"}';
  70.     return $help;
  71. }
  72.  
  73. function data_datamodule$pData$pParams {
  74.     global $gBitThemes$gBitSmarty;
  75.  
  76.     $out '';
  77.     $ret ' ';
  78.  
  79.     extract$pParams EXTR_SKIP );
  80.  
  81.     if!empty$module && !empty$package )) {
  82.         $modules_dir constantstrtoupper$package ).'_PKG_PATH' ).'modules/';
  83.         ifis_file$modules_dir.'mod_'.$module.'.tpl' )) {
  84.             $tpl 'bitpackage:'.$package.'/mod_'.$module.'.tpl';
  85.         else {
  86.             return '<div class="error">'.tra"The module / package combination you entered is not valid" ).'</div>';
  87.         }
  88.     else {
  89.         return '<div class="error">'.tra"Both paramters 'module' and 'package' are required" ).'</div>';
  90.     }
  91.  
  92.     // Setup moduleParams the best we can.
  93.     $moduleParams array();
  94.     $moduleParams['module_params'$pParams;
  95.     ifisset$pParams['rows')) {
  96.         $moduleParams['module_rows'$pParams['rows'];
  97.     else {
  98.         $moduleParams['module_rows'10;
  99.     }
  100.  
  101.     ifisset$pParams['title')) {
  102.         $moduleParams['title'$pParams['title'];
  103.     }
  104.     $gBitSmarty->assign'moduleParams'$moduleParams );
  105.  
  106.     if!$out $gBitSmarty->fetch$tpl ) ) {
  107.         if$gBitThemes->isCustomModule$module ) ) {
  108.             $info $gBitThemes->getCustomModule$module );
  109.             $gBitSmarty->assign_by_ref'user_title'$info["title");
  110.             $gBitSmarty->assign_by_ref'user_data'$info["data");
  111.             $out $gBitSmarty->fetch'modules/user_module.tpl' );
  112.         }
  113.     }
  114.     $out preg_replace"#\n#is"""$out );
  115.  
  116.     // deal with custom styling
  117.     $style '';
  118.     $style_options array'float''width''background''color' );
  119.     foreach$pParams as $param => $value {
  120.         ifin_array$param$style_options ) ) {
  121.             $style .= $param.':'.$value.';';
  122.         }
  123.     }
  124.  
  125.     if!empty$style ) ) {
  126.         $style ' style="'.$style.'"';
  127.     }
  128.  
  129.     if$out {
  130.         $ret '<div'.$style.'>'.$out.'</div>';
  131.     }
  132.     return $ret;
  133. }
  134. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:20 +0000 by phpDocumentor 1.5.0-lsces