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

Source for file data.span.php

Documentation is available at data.span.php

  1. <?php
  2. /**
  3.  * assigned_modules
  4.  *
  5.  * @author     xing
  6.  * @version    $Revision$
  7.  * @package    liberty
  8.  * @subpackage plugins_data
  9.  * @copyright  Copyright (c) 2004, bitweaver.org
  10.  */
  11.  
  12. /**
  13.  * Setup Code
  14.  */
  15. define( 'PLUGIN_GUID_DATAspan', 'dataspan' );
  16. global $gLibertySystem;
  17. $pluginParams = array (
  18.     'tag' => 'span',
  19.     'auto_activate' => FALSE,
  20.     'requires_pair' => TRUE,
  21.     'load_function' => 'data_span',
  22.     'title' => 'Span',
  23.     'help_page' => 'DataPluginspan',
  24.     'description' => tra( "This plugin allows you to easily create a span with a number of optional CSS parameters." ),
  25.     'help_function' => 'data_span_help',
  26.     'syntax' => "{span border='3px solid blue'}",
  27.     'plugin_type' => DATA_PLUGIN
  28. );
  29. $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAspan, $pluginParams );
  30. $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAspan );
  31.  
  32. function data_span_help() {
  33.     $help =
  34.         '<table class="data help">'
  35.             .'<tr>'
  36.                 .'<th>' . tra( "Key" ) . '</th>'
  37.                 .'<th>' . tra( "Type" ) . '</th>'
  38.                 .'<th>' . tra( "Comments" ) . '</th>'
  39.             .'</tr>'
  40.             .'<tr class="odd">'
  41.                 .'<td>' . tra( "CSS rules or class" ) . '</td>'
  42.                 .'<td>' . tra( "string") . '<br />' . tra( "(optional)" ) . '</td>'
  43.                 .'<td>' . tra( "This can be any CSS style rule. e.g.: ") . "font='small-caps 250% serif'" .'</td>'
  44.             .'</tr>'
  45.             .'<tr class="even">'
  46.                 .'<td>preset</td>'
  47.                 .'<td>' . tra( "string") . '<br />' . tra( "(optional)" ) . '</td>'
  48.                 .'<td>' . tra( "There are a few presets, which you can use to style with. Presets include: caps, smallcaps, big, small, strikethrough, overline, spaced, nodecor.") .'</td>'
  49.             .'</tr>'
  50.         .'</table>'
  51.         . tra( "Example: " ) . "{span preset=overline font='small-caps 250% serif'}";
  52.     return $help;
  53. }
  54.  
  55. function data_span( $pData, $pParams, $pCommonObject ) {
  56.     $style = '';
  57.     foreach( $pParams as $key => $value ) {
  58.         if( !empty( $value ) ) {
  59.             switch( $key ) {
  60.                 case 'preset':
  61.                     if( $value == 'caps' ) {
  62.                         $style .= 'text-transform: uppercase;';
  63.                     } elseif( $value == "smallcaps" ) {
  64.                         $style .= 'font-variant: small-caps;';
  65.                     } elseif( $value == "big" ) {
  66.                         $style .= 'font-size: larger;';
  67.                     } elseif( $value == "small" ) {
  68.                         $style .= 'font-size: smaller;';
  69.                     } elseif( $value == "strikethrough" ) {
  70.                         $style .= 'text-decoration: line-through;';
  71.                     } elseif( $value == "spaced" ) {
  72.                         $style .= 'letter-spacing: 1.5em;';
  73.                     } elseif( $value == "overline" ) {
  74.                         $style .= 'text-decoration: overline;';
  75.                     } elseif( $value == "nodecor" ) {
  76.                         $style .= 'text-decoration: none;';
  77.                     }
  78.                     break;
  79.                 case 'style':
  80.                     $style .= $value;
  81.                     break;
  82.                 case 'class':
  83.                     $class = $value;
  84.                     break;
  85.                 default:
  86.                     $style .= $key.':'.$value.';';
  87.                 break;
  88.             }
  89.         }
  90.     }
  91.     // we need to parse the data. we shouldn't cache this to avoid problems with the regular cache file
  92.     $parseHash = $pCommonObject->mInfo;
  93.     $parseHash['no_cache'] = TRUE;
  94.     $parseHash['data'] = $pData;
  95.     $parsedData = $pCommonObject->parseData( $parseHash );
  96.     $parsedData = preg_replace( '|<br\s*/?>$|', '', $parsedData );
  97.     return( '<span '.( !empty( $class ) ? 'class="'.$class.'" ' : '' ).'style="'.$style.'">'.$parsedData.'</span>' );
  98. }
  99. ?>

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