1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00
secretr d5dc6bfe05 - Custom Pages: new fields for SEF string and meta data, admin validation and data control, front-end SEO (meta data), additional 'safe' URL config (for migrated installs); some new useful helper methods;
- More typography and layout control: new class based paragraph, heading, nobr, br and block bbcodes (awaiting new icons) 
- Overall improvements and stability fixes
2011-12-09 02:08:04 +00:00

72 lines
1.8 KiB
PHP

<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Paragraph bbcode
*/
if (!defined('e107_INIT')) { exit; }
/**
* Basic usage [p=CSS-className]text[/p]
* Advanced usage [p=class=className&id=element-id&style=some: style; and: moresStyle]text[/p]
* 'class' defaults to 'bbcode' (if left empty)
*/
class bb_p extends e_bb_base
{
/**
* Called prior to save
* Sanitize and re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
$code_text = trim($code_text);
if(empty($code_text)) return '';
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$parms = eHelper::scParams($parm);
$safe = array();
if(vartrue($parms['class']))
{
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if(vartrue($parms['id']))
{
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if(vartrue($parms['style']))
{
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if($safe)
{
return '[p='.eHelper::buildAttr($safe).']'.$code_text.'[/p]';
}
return '[p]'.$code_text.'[/p]';
}
/**
* Translate to <p> tag
*/
function toHTML($code_text, $parm)
{
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
$code_text = trim($code_text);
$parms = eHelper::scParams($parm);
$class = varsettrue($parms['class']) ? ' class="'.eHelper::secureClassAttr($parms['class']).'"' : '';
if(!$class) $class = ' class="bbcode"';
$id = varsettrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
$style = varsettrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
return "<p{$id}{$class}{$style}>".$code_text.'</p>';
}
}