'PRE',
'auto_activate' => FALSE,
'requires_pair' => TRUE,
'load_function' => 'data_pre',
'title' => 'Pre',
'help_page' => 'DataPluginPre',
'description' => tra( "This plugin allows you to easily create a preformatted text block with a number of optional CSS parameters." ),
'help_function' => 'data_pre_help',
'syntax' => "{pre border='3px solid blue'}",
'plugin_type' => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAPRE, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAPRE );
function data_pre_help() {
$help =
'
'
.''
.'| ' . tra( "Key" ) . ' | '
.'' . tra( "Type" ) . ' | '
.'' . tra( "Comments" ) . ' | '
.'
'
.''
.'| ' . tra( "CSS rules" ) . ' | '
.'' . tra( "string") . ' ' . tra( "(optional)" ) . ' | '
.'' . tra( "This can be any CSS style rule. e.g.: ") . "border='3px solid blue'" .' | '
.'
'
.''
.'| preset | '
.'' . tra( "string") . ' ' . tra( "(optional)" ) . ' | '
.'' . tra( "There are a few presets, which you can use to style with. Presets include: dark, orange, red, blue, centered.") .' | '
.'
'
.'
'
. tra( "Example: " ) . "{pre preset=centered border='3px solid blue'}";
return $help;
}
function data_pre( $pData, $pParams, $pCommonObject, $pParseHash ) {
$style = '';
foreach( $pParams as $key => $value ) {
if( !empty( $value ) ) {
switch( $key ) {
case 'preset':
if( $value == 'dark' ) {
$style .= 'background:#333;color:#ccc;border:2px solid #000;padding:0.5em 1em;margin:0.5em;';
} elseif( $value == "orange" ) {
$style .= 'background:#f60;color:#fff;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
} elseif( $value == "red" ) {
$style .= 'background:#eee;color:#900;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
} elseif( $value == "blue" ) {
$style .= 'background:#def;color:#009;border:2px solid #acf;padding:0.5em 1em;margin:0.5em;';
} elseif( $value == "centered" ) {
$style .= 'background:#eee;color:#333;border:2px solid #ddd;padding:0.5em 1em;margin:0.5em auto;width:50%;text-align:center;';
}
break;
case 'style':
$style .= $value;
break;
case 'class':
$class = $value;
break;
default:
$style .= $key.':'.$value.';';
break;
}
}
}
$parseHash['content_id'] = $pParseHash['content_id'];
$parseHash['user_id'] = $pParseHash['user_id'];
$parseHash['no_cache'] = TRUE;
$parseHash['data'] = $pData;
$ret = ''.$pCommonObject->parseData( $parseHash ).'
';
return $ret;
}
?>