Completed
Push — 16.1 ( afa191...e91d93 )
by Hadi
40:33 queued 23:26
created

Description::beforeSendToClient()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * EGroupware - eTemplate widget baseclass
4
 *
5
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
6
 * @package api
7
 * @subpackage etemplate
8
 * @link http://www.egroupware.org
9
 * @author Ralf Becker <[email protected]>
10
 * @copyright 2002-16 by [email protected]
11
 * @version $Id$
12
 */
13
14
namespace EGroupware\Api\Etemplate\Widget;
15
16
use EGroupware\Api\Etemplate;
17
18
/**
19
 * Description widget
20
 *
21
 * Reimplemented to set legacy options
22
 */
23
class Description extends Etemplate\Widget
24
{
25
	/**
26
	 * (Array of) comma-separated list of legacy options to automatically replace when parsing with set_attrs
27
	 *
28
	 * @var string|array
29
	 */
30
	protected $legacy_options = 'bold-italic,link,activate_links,label_for,link_target,link_popup_size,link_title';
31
32
	/**
33
	 * Set up what we know on the server side.
34
	 *
35
	 * Encode html specialchars (eg. < to &lt;) because client-side core
36
	 * widget runs decoding for the value causes elimination of none
37
	 * encoded html chars. This will help included links inside description
38
	 * get displayed if activate_links = ture for description widget is set.
39
	 *
40
	 * @param string $cname
41
	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
42
	 */
43
	public function beforeSendToClient($cname, array $expand=null)
44
	{
45
		if ($this->attrs['activate_links'])
46
		{
47
			$form_name = self::form_name($cname, $this->id, $expand);
48
			$value =& self::get_array(self::$request->content, $form_name);
49
			if (!empty($value))
50
			{
51
				$value = htmlspecialchars($value);
52
			}
53
		}
54
	}
55
}
56