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

Source for file data.quote.php

Documentation is available at data.quote.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2005, 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): Gustavo Muslera <gmuslera@users.sourceforge.net>
  17. // | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
  18. // | by: wjames5
  19. // | Reworked from: data.articles.php from wikiplugin_articles.php
  20. // +----------------------------------------------------------------------+
  21. // $Id$
  22.  
  23. /**
  24.  * definitions
  25.  */
  26. global $gBitSystem, $gBitSmarty;
  27. define( 'PLUGIN_GUID_DATAQUOTE', 'dataquote' );
  28. global $gLibertySystem;
  29. $pluginParams = array (
  30.     'tag'           => 'quote',
  31.     'auto_activate' => FALSE,
  32.     'requires_pair' => TRUE,
  33.     'load_function' => 'data_quote',
  34.     'help_function' => 'data_quote_help',
  35.     'title'         => 'Quote',
  36.     'help_page'     => 'DataPluginQuote',
  37.     'description'   => tra( "This plugin allows content to be attributed to other authors and visually indicated." ),
  38.     'syntax'        => "{quote format_guid= user= comment_id= }.. content ..{/quote}",
  39.     'plugin_type'   => DATA_PLUGIN
  40. );
  41. $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAQUOTE, $pluginParams );
  42. $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAQUOTE );
  43.  
  44. // Help Routine
  45. function data_quote_help() {
  46.     $help ="<table class=\"data help\">
  47.             <tr>
  48.                 <th>" . tra( "Key" ) . "</th>
  49.                 <th>" . tra( "Type" ) . "</th>
  50.                 <th>" . tra( "Comments" ) . "</th>
  51.             </tr>
  52.             <tr class=\"even\">
  53.                 <td>comment_id</td>
  54.                 <td>" . tra( "comment_id") . '<br />' . tra("(optional)") . "</td>
  55.                 <td>" . tra( "specify the comment_id of the comment being quoted") . "</td>
  56.             </tr>
  57.             <tr class=\"odd\">
  58.                 <td>user</td>
  59.                 <td>" . tra( "user") . '<br />' . tra("(optional)") . "</td>
  60.                 <td>" . tra( "specify the user whose comemnt is being quoted") . "</td>
  61.             </tr>
  62.             <tr class=\"even\">
  63.                 <td>format_guid</td>
  64.                 <td>" . tra( "string") . '<br />' . tra("(required)") . "</td>
  65.                 <td>" . tra( "Specify what renderer should be used to render the contents") . "</td>
  66.             </tr>
  67.         </table>".
  68.     tra("Example: ") . '{quote format_guid="tikiwiki" comment_id="7" user="user"} ... {/quote}<br />';
  69.     return $help;
  70. }
  71.  
  72. // Executable Routine
  73. function data_quote( $pData, $pParams ) {
  74.     global $gLibertySystem, $gBitSmarty, $gBitSystem;
  75.  
  76.     if( empty( $pParams['format_guid'] )) {
  77.         // default should be set - if not, we'll use tikiwiki - can't use PLUGIN_GUID_TIKIWIKI since it might not be defined.
  78.         $pParams['format_guid'] = $gBitSystem->getConfig( 'default_format', 'tikiwiki' );
  79.     }
  80.  
  81.     $rendererHash = array();
  82.     $rendererHash['content_id'] = 0;
  83.     $rendererHash['format_guid'] = $pParams['format_guid'];
  84.     $rendererHash['data'] = trim( $pData );
  85.     $formatGuid = $rendererHash['format_guid'];
  86.     $ret = "";
  87.  
  88.     if( $func = $gLibertySystem->getPluginFunction( $formatGuid, 'load_function' ) ) {
  89.         $ret = $func( $rendererHash, $this );
  90.     }
  91.  
  92.     $quote = array();
  93.     $user = empty( $pParams['user'] ) ? NULL : $pParams['user'];
  94.  
  95.     if( !empty( $pParams['comment_id'] )) {
  96.         
  97.         if( ACTIVE_PACKAGE == 'boards' ) {
  98.             $c = new BitBoardPost( preg_replace( '/[^0-9]/', '', $pParams['comment_id'] ) );
  99.         } else {
  100.             $c = new LibertyComment( preg_replace( '/[^0-9]/', '', $pParams['comment_id'] ) );
  101.         }
  102.  
  103.         if( empty( $c->mInfo['title'] )) {
  104.             $c->mInfo['title'] = "#".$c->mCommentId;
  105.         }
  106.  
  107.         $quote['cite_url'] = $c->getDisplayUrl();
  108.         $quote['title'] = $c->mInfo['title'];
  109.         $quote['created'] = $c->mInfo['created'];
  110.  
  111.         if( empty( $user )) {
  112.             $user = $c->mInfo['login'];
  113.         }
  114.     }
  115.  
  116.     $quote['login'] = $user;
  117.  
  118.     if( !empty( $user )) {
  119.         $u = new BitUser();
  120.         $u->load( TRUE, $user );
  121.  
  122.         $quote['user_url'] = $u->getDisplayUrl();
  123.         $quote['user_display_name'] = $u->mInfo['display_name'];
  124.     }
  125.  
  126.     $quote['ret'] = $ret;
  127.  
  128.     $gBitSmarty->assign( "quote", $quote );
  129.     $repl = $gBitSmarty->fetch( "bitpackage:liberty/plugins/data_quote.tpl" );
  130.  
  131.     return $repl;
  132. }
  133. ?>

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