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

Source for file data.addjstabs.php

Documentation is available at data.addjstabs.php

  1. <?php
  2. /**
  3.  * Liberty Plugin - jstabs
  4.  *
  5.  * @copyright (c) 2015, bitweaver.org
  6.  * @author StarRider <starrrider@users.sourceforge.net>
  7.  *  port to jstabs <lester@lsces.co.uk>
  8.  *
  9.  * @package  liberty
  10.  * @subpackage plugins_data
  11.  */
  12.  
  13. /**
  14.  * definitions
  15.  */
  16. define( 'PLUGIN_GUID_DATAADDJSTABS', 'dataaddjstabs' );
  17. global $gLibertySystem;
  18. global $gContent;
  19. $pluginParams = array (
  20.     'tag' => 'ADDJSTABS',
  21.     'auto_activate' => FALSE,
  22.     'requires_pair' => FALSE,
  23.     'load_function' => 'data_addjstabs',
  24.     'title' => 'AddJSTabs',
  25.     'help_page' => 'DataPluginAddJSTabs',
  26.     'description' => tra("Will join the contents from several sources in a Tabbed Interface."),
  27.     'help_function' => 'data_addjstabs_help',
  28.     'syntax' => "{ADDJSTABS tab1= tab2= tab3= . . . tab99= }",
  29.     'plugin_type' => DATA_PLUGIN
  30. );
  31. $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAADDJSTABS, $pluginParams );
  32. $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAADDJSTABS );
  33.  
  34. /**
  35.  * Help Function
  36.  */
  37. function data_addjstabs_help() {
  38.     $help =
  39.         '<table class="data help">'
  40.             .'<tr>'
  41.                 .'<th>' . tra( "Key" ) . '</th>'
  42.                 .'<th>' . tra( "Type" ) . '</th>'
  43.                 .'<th>' . tra( "Comments" ) . '</th>'
  44.             .'</tr>'
  45.             .'<tr class="odd">'
  46.                 .'<td>tab1 - tab99</td>'
  47.                 .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
  48.                 .'<td>' . tra( "Will create a Tab interface on a page using jstab format. The name on each tab is the name given to the imported page.The value sent with the TabX parameter is a Numeric Content Id. This allows blog posts, images, wiki pages . . . (and more) to be added.")
  49.                 . tra("<br /><strong>Note 1:</strong> A listing of Content Id's can be found ")
  50.                 . '<a href="'.LIBERTY_PKG_URL.'list_content.php" title="Launch BitWeaver Content Browser in New Window" onkeypress="javascript:BitBase.popUpWin(this.href,\'standard\',800,800);" onclick="javascript:BitBase.popUpWin(this.href,\'standard\',800,800);return false;">' . tra( "Here" ) . '</a>'
  51.                 . tra("<br /><strong>Note 2:</strong> The order used when the tabs are specified does not matter. The Tabname does - Tab1 is always first and Tab99 will always be last.</td>")
  52.             .'</tr>'
  53.         .'</table>'
  54.         . tra("Example: ") . '{ADDJSTABS tab1=15 tab2=12 tab3=11}';
  55.     return $help;
  56. }
  57.  
  58.  
  59. /**
  60.  * Function body
  61.  * 
  62.  * @param string $data 
  63.  * @param array $params See help function for details
  64.  */
  65. function data_addjstabs($data, $params) {
  66.     global $gBitSmarty;
  67.     $gBitSmarty->loadPlugin( 'smarty_block_jstab' );
  68.     $gBitSmarty->loadPlugin( 'smarty_block_jstabs' );
  69.  
  70.     extract ($params, EXTR_SKIP);
  71.     $id = 1000000 * microtime();
  72.     $html = '';
  73.     $good = false;
  74.  
  75.     for ($i = 1; $i <= 99; $i++) {
  76.         if( isset( ${'tab'.$i} ) ) {
  77.             if (is_numeric( ${'tab'.$i} ) ) {
  78.                 if( $obj = LibertyBase::getLibertyObject( ${'tab'.$i} ) ) {
  79.                     $params['title'] = $obj->getTitle();
  80.                     $html .= smarty_block_jstab( $params, $obj->mInfo['parsed_data'], $gBitSmarty, '' );
  81.                     $good=True;
  82.                 }
  83.             }
  84.             else {
  85.                 $good=false;
  86.             }
  87.         }
  88.     }
  89.     if( !$good ) {
  90.         $html = tra("The plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'");
  91.     }
  92.     if( !empty( $html )) {
  93.         return smarty_block_jstabs( array(), $html, $gBitSmarty, '' );
  94.     } else {
  95.         return $html;
  96.     }
  97. }
  98. ?>

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