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

Source for file data.pre.php

Documentation is available at data.pre.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_DATAPRE''datapre' );
  16. global $gLibertySystem;
  17. $pluginParams array (
  18.     'tag'           => 'PRE',
  19.     'auto_activate' => FALSE,
  20.     'requires_pair' => TRUE,
  21.     'load_function' => 'data_pre',
  22.     'title'         => 'Pre',
  23.     'help_page'     => 'DataPluginPre',
  24.     'description'   => tra"This plugin allows you to easily create a preformatted text block with a number of optional CSS parameters." ),
  25.     'help_function' => 'data_pre_help',
  26.     'syntax'        => "{pre border='3px solid blue'}",
  27.     'plugin_type'   => DATA_PLUGIN
  28. );
  29. $gLibertySystem->registerPluginPLUGIN_GUID_DATAPRE$pluginParams );
  30. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAPRE );
  31.  
  32. function data_pre_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" '</td>'
  42.                 .'<td>' tra"string"'<br />' tra"(optional)" '</td>'
  43.                 .'<td>' tra"This can be any CSS style rule. e.g.: ""border='3px solid blue'" .'</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: dark, orange, red, blue, centered.".'</td>'
  49.             .'</tr>'
  50.         .'</table>'
  51.         . tra"Example: " "{pre preset=centered border='3px solid blue'}";
  52.     return $help;
  53. }
  54.  
  55. function data_pre$pData$pParams$pCommonObject$pParseHash {
  56.     $style '';
  57.     foreach$pParams as $key => $value {
  58.         if!empty$value ) ) {
  59.             switch$key {
  60.                 case 'preset':
  61.                     if$value == 'dark' {
  62.                         $style .= 'background:#333;color:#ccc;border:2px solid #000;padding:0.5em 1em;margin:0.5em;';
  63.                     elseif$value == "orange" {
  64.                         $style .= 'background:#f60;color:#fff;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
  65.                     elseif$value == "red" {
  66.                         $style .= 'background:#eee;color:#900;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
  67.                     elseif$value == "blue" {
  68.                         $style .= 'background:#def;color:#009;border:2px solid #acf;padding:0.5em 1em;margin:0.5em;';
  69.                     elseif$value == "centered" {
  70.                         $style .= 'background:#eee;color:#333;border:2px solid #ddd;padding:0.5em 1em;margin:0.5em auto;width:50%;text-align:center;';
  71.                     }
  72.                     break;
  73.                 case 'style':
  74.                     $style .= $value;
  75.                     break;
  76.                 case 'class':
  77.                     $class $value;
  78.                     break;
  79.                 default:
  80.                     $style .= $key.':'.$value.';';
  81.                 break;
  82.             }
  83.         }
  84.     }
  85.     $parseHash['content_id'$pParseHash['content_id'];
  86.     $parseHash['user_id'$pParseHash['user_id'];
  87.     $parseHash['no_cache'TRUE;
  88.     $parseHash['data'$pData;
  89.     $ret '<pre '.!empty$class 'class="'.$class.'" ' '' ).'style="'.$style.'">'.$pCommonObject->parseData$parseHash ).'</pre>';
  90.     return $ret;
  91. }
  92. ?>

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