1
0
mirror of https://github.com/EGroupware/egroupware.git synced 2024-12-24 07:39:27 +01:00
egroupware_official/etemplate/inc/class.etemplate_widget_htmlarea.inc.php

78 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/**
* EGroupware - eTemplate serverside htmlarea widget
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-11 by RalfBecker@outdoor-training.de
* @version $Id$
*/
/**
* eTemplate htmlarea widget
*/
class etemplate_widget_htmlarea extends etemplate_widget
{
2012-06-06 06:13:19 +02:00
protected $legacy_options = 'mode,height,width,expand_toolbar,base_href';
public $attrs = array(
'height' => '400px',
);
/**
* Fill config options
*
* @param string $cname
*/
public function beforeSendToClient($cname)
{
$form_name = self::form_name($cname, $this->id);
2012-06-06 06:13:19 +02:00
$config = egw_ckeditor_config::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'],
$this->attrs['expand_toolbar'],$this->attrs['base_href']
);
2014-06-30 23:28:03 +02:00
// User preferences
$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
$font_size = egw_ckeditor_config::font_size_from_prefs();
$font_span = '<span '.($font||$font_size?'style="':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
if (empty($font) && empty($font_size)) $font_span = '';
if($font_span)
{
$config['preference_style'] = $font_span;
}
2012-06-06 06:13:19 +02:00
self::$request->modifications[$form_name]['config'] = $config;
}
/**
* Validate input
*
* Input is run throught HTMLpurifier, to make sure users can NOT enter javascript or other nasty stuff (XSS!).
*
* @param string $cname current namespace
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
* @param array $content
* @param array &$validated=array() validated content
* @return boolean true if no validation error, false otherwise
*/
public function validate($cname, array $expand, array $content, &$validated=array())
{
$form_name = self::form_name($cname, $this->id, $expand);
if (!$this->is_readonly($cname, $form_name))
{
2011-08-21 15:45:55 +02:00
$value = self::get_array($content, $form_name);
// only purify for html, mode "ascii" is NO html and content get lost!
if ($this->attrs['mode'] != 'ascii')
{
$value = html::purify($value, $this->attrs['validation_rules']);
}
$valid =& self::get_array($validated, $form_name, true);
if (true) $valid = $value;
}
}
}