Completed
Push — master ( 35968b...428775 )
by Khoa
03:36
created

word_desc::get_text_for_edit()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
* This file is part of the VinaBB.vn package.
4
*
5
* @copyright (c) VinaBB <vinabb.vn>
6
* @license GNU General Public License, version 2 (GPL-2.0)
7
*/
8
9
namespace vinabb\web\entities\sub;
10
11
use vinabb\web\entities\abs\bbcode_content;
12
13
/**
14
* Sub-entity for bbook_word/word_desc
15
*/
16
class word_desc extends bbcode_content
17
{
18
	/** @var array $data */
19
	protected $data;
20
21
	/** @var bool $ignore_max_post_chars */
22
	protected $ignore_max_post_chars = false;
23
24
	/** @var string $prefix */
25
	protected $prefix = 'word_desc';
26
27
	/**
28
	* Get word explanation for edit
29
	*
30
	* @return string
31
	*/
32
	public function get_text_for_edit()
33
	{
34
		return $this->get_for_edit($this->prefix);
35
	}
36
37
	/**
38
	* Get word explanation for display
39
	*
40
	* @param bool $censor True to censor the text
41
	* @return string
42
	*/
43
	public function get_text_for_display($censor = true)
44
	{
45
		return $this->get_for_display($this->prefix, $censor);
46
	}
47
48
	/**
49
	* Set word explanation
50
	*
51
	* @param string		$text	Word explanation
52
	* @return word_desc	$this	Object for chaining calls: load()->set()->save()
53
	* @throws \vinabb\web\exceptions\unexpected_value
54
	*/
55
	public function set_text($text)
56
	{
57
		$text = (string) $text;
58
59
		// This is a required field
60
		if ($text == '')
61
		{
62
			throw new \vinabb\web\exceptions\unexpected_value(['word_desc', 'EMPTY']);
63
		}
64
65
		return $this->set($this->prefix, $text);
66
	}
67
68
	/**
69
	* Check if BBCode is enabled on the word explanation
70
	*
71
	* @return bool
72
	*/
73
	public function text_bbcode_enabled()
74
	{
75
		return $this->bbcode_enabled($this->prefix);
76
	}
77
78
	/**
79
	* Enable/Disable BBCode on the word explanation
80
	* This should be called before set_text(); text_enable_bbcode()->set_text()
81
	*
82
	* @param bool		$enable	true: enable; false: disable
83
	* @return word_desc	$this	Object for chaining calls: load()->set()->save()
84
	*/
85
	public function text_enable_bbcode($enable)
86
	{
87
		return $this->enable_bbcode($this->prefix, $enable);
88
	}
89
90
	/**
91
	* Check if URLs is enabled on the word explanation
92
	*
93
	* @return bool
94
	*/
95
	public function text_urls_enabled()
96
	{
97
		return $this->urls_enabled($this->prefix);
98
	}
99
100
	/**
101
	* Enable/Disable URLs on the word explanation
102
	* This should be called before set_text(); text_enable_urls()->set_text()
103
	*
104
	* @param bool		$enable	true: enable; false: disable
105
	* @return word_desc	$this	Object for chaining calls: load()->set()->save()
106
	*/
107
	public function text_enable_urls($enable)
108
	{
109
		return $this->enable_urls($this->prefix, $enable);
110
	}
111
112
	/**
113
	* Check if smilies are enabled on the word explanation
114
	*
115
	* @return bool
116
	*/
117
	public function text_smilies_enabled()
118
	{
119
		return $this->smilies_enabled($this->prefix);
120
	}
121
122
	/**
123
	* Enable/Disable smilies on the word explanation
124
	* This should be called before set_text(); text_enable_smilies()->set_text()
125
	*
126
	* @param bool		$enable	true: enable; false: disable
127
	* @return word_desc	$this	Object for chaining calls: load()->set()->save()
128
	*/
129
	public function text_enable_smilies($enable)
130
	{
131
		return $this->enable_smilies($this->prefix, $enable);
132
	}
133
}
134